locked
CRYSTAL REPORTS: HOW TO CHANGE DATE FORMAT OF CRYSTAL REPORT FIELD FROM ASP.NET 2.0 RRS feed

  • Question

  • User158093232 posted

    Hi All,

    I have a crystal report document which is opened from my asp.net 2.0 application (C# code). In the design time i fixed my date fields as MM/dd/yyyy format.

    but now we are going to implement the project in different culture. so now i need to change the format of date field at run time thru asp.net 2.0 (C#).

    Help is highly appriciated.

    Thanks in Advance.

    Tuesday, March 4, 2008 2:04 AM

Answers

  • User158093232 posted

    hi all,

    i got solution for this problem.

    when we need to change the format of a date field or number field or string field, we can use the parameters.

    Do the following to format the date field.

    1. create a parameter that accepts number values.

    2. Right click on your date field and choose format field.

    3. go to the datetime tab and click on the formula section for "Order".

    4. insert your parameter here and save.

    5. now the selected date field is formated as per the given format

    6. 0 - YMD; 1-DMY; 2-MDY. these are the numbers can be given by the parameter from your application.

     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, March 5, 2008 12:48 AM

All replies

  • User-77359003 posted

    hi you can use the following formats if you are fecting form  DataBase

    SELECT Lower(CONVERT(VARCHAR,GETDATE(),100)) -- May 23 2007 6:00PM

    SELECT CONVERT(VARCHAR,GETDATE(),101) -- 05/23/2007

    SELECT CONVERT(VARCHAR,GETDATE(),102) -- 2007.05.23

    SELECT CONVERT(VARCHAR,GETDATE(),103) -- 23/05/2007

    SELECT CONVERT(VARCHAR,GETDATE(),104) -- 23.05.2007

    SELECT CONVERT(VARCHAR,GETDATE(),105) -- 23-05-2007

    SELECT CONVERT(VARCHAR,GETDATE(),106) -- 23 May 2007

    SELECT CONVERT(VARCHAR,GETDATE(),107) -- May 23, 2007

    SELECT CONVERT(VARCHAR,GETDATE(),108) -- 18:02:03

    SELECT CONVERT(VARCHAR,GETDATE(),109) -- May 23 2007 6:02:28:177PM

    SELECT CONVERT(VARCHAR,GETDATE(),110) -- 05-23-2007

    SELECT CONVERT(VARCHAR,GETDATE(),111) -- 2007/05/23

    SELECT CONVERT(VARCHAR,GETDATE(),112) -- 20070523

    SELECT CONVERT(VARCHAR,GETDATE(),113) -- 23 May 2007 18:02:51:850

    SELECT CONVERT(VARCHAR,GETDATE(),114) -- 18:02:57:083

    SELECT CONVERT(VARCHAR,GETutcDATE()),114) -- 18:02:57:083

    SELECT CONVERT(VARCHAR,GETDATE()),114) -- 18:02:57:083

    SELECT DATEPART(HOUR,CONVERT(VARCHAR,HOUR(GETDATE()),109)) -- 18:02:57:083

    try this if not working let me know

    Viswanath 

    Mark as answer if it helps

     

    Tuesday, March 4, 2008 5:37 AM
  • User158093232 posted

    thanks for your reply.

    but i am not asking this. i go to change the entire dates format of my application. at that time i can't modify the queries.

    so i need to give a format (dmy/ mdy) to crystal report to show the date.

    this format passing may be a attribute or parameter for the report.

    help me.

    thanks in advance.

    Tuesday, March 4, 2008 5:58 AM
  • User158093232 posted

    hi all,

    i got solution for this problem.

    when we need to change the format of a date field or number field or string field, we can use the parameters.

    Do the following to format the date field.

    1. create a parameter that accepts number values.

    2. Right click on your date field and choose format field.

    3. go to the datetime tab and click on the formula section for "Order".

    4. insert your parameter here and save.

    5. now the selected date field is formated as per the given format

    6. 0 - YMD; 1-DMY; 2-MDY. these are the numbers can be given by the parameter from your application.

     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, March 5, 2008 12:48 AM
  • User-249501588 posted

    Hey all,

    Thanks alots for the trick you sent which is working fine in normal report. I have the same problem but in "Cross Tab", I need to show Date sorted in descending order but the date format will comes from application whether it is "yyyy/MM/dd", "dd/MM/yyyy" or "MM/dd/yyyy", application will decide which date format will be seen on report dynamically. I have tried same trick in cross tab but it is not working.

    Please Help!

    Mehsam

    hi all,

    i got solution for this problem.

    when we need to change the format of a date field or number field or string field, we can use the parameters.

    Do the following to format the date field.

    1. create a parameter that accepts number values.

    2. Right click on your date field and choose format field.

    3. go to the datetime tab and click on the formula section for "Order".

    4. insert your parameter here and save.

    5. now the selected date field is formated as per the given format

    6. 0 - YMD; 1-DMY; 2-MDY. these are the numbers can be given by the parameter from your application.

     

    Wednesday, September 21, 2011 7:23 AM