cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

ToText default format for DateTime values

afanofosc
Discoverer
0 Likes
1,233

I have a formula displayed in the top right corner of many reports called CurrentDateTimeString. The formula is ToText(CurrentDateTime). What I want to know is exactly what Windows OS regional settings are being used by Crystal to convert that DateTime to a string when no format is specified in the ToText function. Is this documented anywhere?

Accepted Solutions (0)

Answers (2)

Answers (2)

DellSC
Active Contributor
0 Likes

Another option instead of using ToText:

1. Put a text box on the report where you want to show the date time.

2. Pull the Data Date special field into the text box.

3. Put your cursor at the end of DataDate in the text box and add a space.

4. Pull the Data Time special field into the text box.

This will show the DateTime in the format that you want it.

-Dell

afanofosc
Discoverer
0 Likes

Changing the hundreds of report format files that we have is not an option. What I need is someone from SAP who knows to tell me what Crystal is using to decide how to format a DateTime value using ToText without a format specified. It should be using the ShortDatePattern and LongTimePattern that I am customizing but it is not.

DellSC
Active Contributor
0 Likes

I believe it will use whatever the Windows Default format is for the computer where it's being run.

-Dell

afanofosc
Discoverer
0 Likes

That is definitely not what Crystal does. There is no "Windows Default format" for a combined Date and Time value. In C# there is a "standard format" called "G" which is not defined at the OS level. For C# that means "short date plus a space plus long time" but in our software prior to running a Crystal report using the .Net C# classes provided by Crystal if I change the current thread CultureInfo DateTimeFormatInfo object's ShortDatePattern and its LongTimePattern Crystal is ignoring those changes when it outputs a full DateTime value using ToText in a report but it is using the ShortDatePattern when it formats a Date field on the same report. The ToText(CurrentDateTime) field is set to "use default" formatting, i.e., not custom field formatting. The same is true for the Date fields. But nothing I have tried is able to convince Crystal to use the custom ShortDatePattern and LongTimePattern values that I have specified for the current thread when it outputs a DateTime value using the ToText function with no format specified.