Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Customizing ShortDate format 1

Status
Not open for further replies.

robertr10

IS-IT--Management
Dec 20, 2004
3
US
I need to distribute a report that contains a number of date columns. As a result, the maximum number of report positions that I want to use is 8 (ex. mm/dd/yy). But, the recipient of the report definition may be located around the world where the proper format can be dd/mm/yy or yy/mm/dd.

The Windows ShortDate format does handle the proper sequence for the month, day, and year. But, the user may have their short date year set to YYYY... or their short date month set to MMM. Can I use the ShortDate format in a formula and somehow force the year portion to YY and the month portion to MM?
 
I think that you're asking to use the short date default, unless it isn't right, for whatever place they are...

Doesn't see plausible nor logical to me.

You can force a specfic date format, but it isn't universal, so a local change to their preferred settings will mess it up.

-k
 
You can make the date format unchanging by expressing it through a formula field, something like
ToText({your.date}, "dd/MM/yy")
Is that what you were looking for?


[yinyang] Madawc Williams (East Anglia, UK) [yinyang]
 
I'm sorry for any confusion in my original post. Maybe I can clarify it a bit.

The reason that I referred to the Windows ShortDate format was to obtain the sequencing of the month, day, and year for any user that has my report definition. My interest is getting Crystal to print dates using a fixed 8 character format while using the desired sequence for the end user (example: YY/MM/DD, MM/DD/YY, DD/MM/YY). The ShortDate type properly gives me the sequencing, but also produces a YYYY format if the report user has their short date set that way. String functions do not seem appropriate as I do not know how many year positions are defined in the end users ShortDate format... or even which positions it will appear.

If there is a way to extract each portion of the date into its own field from the ShortDate format I'd have what I need.
 
String functions have always worked for me. And I think a date is always the same thing internally to Crystal, however the users may choose to have it displayed.

To get parts of a date, you could do ToText({your.date}, "dd") etc. But I don't think it is necessary.

Where a date is a string you can use Left, Mid and Right to chop it into portions. But this is mostly not necessary.

Why don't you try a test report and see how it runs for the different users.

[yinyang] Madawc Williams (East Anglia, UK) [yinyang]
 
Maybe you could use a parameter {?dateformat} where the user enters their current date format and then you write an if/then formula that translates their date format into a 8-character format using their sequence, as in:

if {?dateformat} in ["dd/MM/yyyy","dd/MM/yy"] then
totext({table.date},"dd/MM/yy") else
if {?dateformat} in ["MM/dd/yyyy","MM/dd/yy"] then
totext({table.date},"MM/dd/yy") else //etc.

-LB
 
LB,

Thanks for your post. The reports are part of a larger application that already has a user interface with Crystal. I think that a new data field in the database that identifies the possible date formats is warranted here.

Per your suggestion, the reports would use the new field from the database plus the formula you have shown for each date on a report. This gets around having to use ShortDate at all.

Robertr10
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top