Hello, my applications usually run on computers with a M/d/yyyy (English (United Sates)) system short date format. I have been running into issues on systems that have the system short date defined as dd/MM/yyyy (English (Canada)). I am repairing instances where there is a string to date conversion like "date(ls_mydate)". This will require testing and may introduce bugs.
The largest problem I've run into are the datawindow functions SaveAs and ImportFile. These appear to use the system date format when writing and reading. We export some files that are imported by other systems that expect a date format of "M/d/yyyy". I'd like a stable way to read and write files that have dates in them that is not tied to the system's short date format.
I have a few questions:
1) Is there a way to override the system's short date format for a Powerbuilder app?
2) Is there a way to set the date format that SaveAs and ImportFile use to write dates to a file?
3) What do you do to deal with issues like this? Make it a requirement that the regional settings are set to a specified type?
The apps are currently PB 12 but we are on the way to Appeon PB, hopefully by the end of the year.
You either
1) Use a Display Format of [General] and let the PB runtime select that format based on the App user's regional setting. // OR
2) Use a Display format of "MM/DD/YY" by default and change this to "DD/MM/YY" when an EU user is detected (via using an "expression")
3) Use two DWO's (one US and one EU tailored) to display & handle dates (both Display & Edit masks) accordingly
Food for thought. HTH
Regards ... Chris
4) Create code in a reusable object that examines the display formats for all column and computed fields and changes them as needed in DW/DS Constructor/post-constructor event or whenever else a data object is assigned to a DataWindow Control or DataStore. This would allow you to any number of date/datetime display formats.
*******************
ls_dateformat = fn_get_displaydate_format()
dw_header.Modify('insertdate' + '.editmask.mask = "' + ls_dateformat + '"')
dw_header.Modify('insertdate' + '.editmask.useformat = "yes"' )
dw_header.Modify('insertdate' + '.format = "' + ls_dateformat + '"')
*******************
HTH