SAP Knowledge Base Article - Public

1211289 - Date displays differently on different computer, when using the function "ToText" in Crystal Reports

Symptom

  • Date format incorrect.
  • Date displays as expected on one computer, but not on the next computer.
  • When converting a date field to string in Crystal Reports, using the function: ToText, it displays the date in different format depending on which computer the report is viewed.

Environment

  • SAP Crystal Reports 2008
  • SAP Crystal Reports 2011
  • SAP Crystal Reports 2013
  • SAP Crystal Reports 2016

Reproducing the Issue

  1. In Crystal Reports, create a report off any data source.
  2. Create a formula that converts a date field, or date time field to string using the function: ToText, like:
             
         ToText({Date Field})
            
  3. Insert the formula on the report.
  4. When refreshing the report, it displays the date in month/day/year like:  12/9/2013
  5. But when refreshing the same report on a different computer it displays the date like: 2013/12/09
         
    Why is the date displayed in different format?

Cause

  • When using the function: ToText, to convert a date field or date time field to a string, if no arguments are added to the ToText function to specify the date format, it will use the computer regional setting date format. This is why the date format can be different when viewing the same report on different computer, because each computer could potentially have a different regional setting.

Resolution

  • To ensure the date format is always the same, add the arguments to the ToText function to specify the desired date format, using the following values:
         
    • d             Day of month without leading zero for single digits.
    • dd            Day of month with leading zero for single digits.    
    • ddd          Day of week as a three letter abreviation. 
    • dddd        Full name of day of week.
    • M             Month without leading zero for single digits.
    • MM           Month with leading zero for single digits.  
    • MMM         Month as a three letter abreviation.
    • MMMM       Full name of the month.
    • yy             Last 2 digits of the year.
    • yyyy          Full four digits of year. 
         
        
      Example: If we want the date to display in the format: month, day, year like:  12/31/2013, then the formula will be like:
         
      ToText({Date Field},"MM/dd/yyyy")

Keywords

DATETIME DATE DATES DATE STRING FORMULA CONVERT STRING TO DATE Seagate Crystal Reports Converting strings to dates Converting 2-digit year to 4-digit year , c2005583 , KBA , BI-RA-CR , Crystal Reports designer or Business View Manager , How To

Product

Crystal Reports 2008 V1 ; SAP Crystal Reports 2011 ; SAP Crystal Reports 2013 ; SAP Crystal Reports 2016