1. Kelly Kranabetter
  2. PowerBuilder
  3. Tuesday, 13 November 2018 20:30 PM UTC

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.


Igor G Accepted Answer Pending Moderation
  1. Thursday, 11 January 2024 17:03 PM UTC
  2. PowerBuilder
  3. # 1


I know this is an older thread, but it's my issue exactly.

I understand the suggestions regarding the ANSI format; good to know.

However, I'd like to display "MM/DD/YY" to American users and "DD/MM/YY" to others, as that's what they are used to working with.

How can I display different formats/masks based on the local settings?

Many thanks,



  1. Chris Pollach @Appeon
  2. Thursday, 11 January 2024 17:50 PM UTC
Hi Igor;

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
  1. Helpful
  1. John Fauss
  2. Thursday, 11 January 2024 18:39 PM UTC
@Igor - or...

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.
  1. Helpful
  1. Sivaprakash BKR
  2. Friday, 12 January 2024 05:41 AM UTC
We have a setup window, where end user will choose their desired format. And the below code to set that format to each and every date fields in a datawindow.


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 + '"')



  1. Helpful
There are no comments made yet.
Olan Knight Accepted Answer Pending Moderation
  1. Wednesday, 14 November 2018 05:12 AM UTC
  2. PowerBuilder
  3. # 2

Chris is absolutely correct: always convert all dates to a YYYYMMDD format.
You san sort on that format, it's concise and clear and is absolutely unambiguous.



There are no comments made yet.
Chris Pollach @Appeon Accepted Answer Pending Moderation
  1. Tuesday, 13 November 2018 21:05 PM UTC
  2. PowerBuilder
  3. # 3

Hi Kelly;

  Being in Canada myself and having to deal with many PB Apps that use dates across various countries - the key to remember is that the MS-Windows O/S and even most DBMS, use the system date internally as "YYYY-MM-DD" (which is the ANSI Standard BTW). So the key to processing dates between O/S factions, external Apps, RESTful calls, etc is to always convert the date into ANSI format.

  For example:

Date   ld_date

ld_date = Date ("2018-10-13")

DC/DS.SetItem (, , ld_date)

Tip: Use a DW Object that does not have any Display or Edit Mask on the date column(s) so they format in ANSI standard. Note that this may not be the DWO that the user currently sees. Its another DWO designed for Exporting and/or Importing dates in ANSI date format (same for Time as well) for a smooth interchange.


Regards ... Chris

  1. Roland Smith
  2. Thursday, 11 January 2024 18:51 PM UTC
In the US, SaveAs to Text formats it m/d/yyyy which I guess is based on the system default. Can we control the format in SaveAs without resorting to manually writing the data one row at a time?
  1. Helpful
There are no comments made yet.
  • Page :
  • 1

There are no replies made for this question yet.
However, you are not allowed to reply to this question.