Date format

Subhransu

Member
Hi,
I wonder if a date can be stored in some different format than it appears on the screen. In other words, if a date is shown as dd/mm/yyyy, how can it be stored in mm/dd/yyyy format in a DB. Secondly, can two different date fields in a table have different formats such as dd/mm/yyyy and mm/dd/yyyy? I am asking because I had never seen such a scenario while working prior to Openedge 10.2b.


Thanks.
Subhransu
 

Subhransu

Member
Hi,
Yes, for instance while preparing an input file to upload some data into a table.
You never know which format to use untill you try a test run.

Thanks.
Subhransu
 

TomBascom

Curmudgeon
Internally dates are stored in a neutral format that has nothing to do with the display format or the export format. Specifically they are stored as an integer offset from Chip Ziering's birthday. For display purposes they are converted to the format specified in the FORMAT phrase. Default formats are influenced by the -yy and -d startup parameters and session attributes (session:date-format = "mdy").

So, no you cannot store dates in the database in different formats because they all use the same internal representation. But that doesn't really matter because what you want to do is to output the date in different formats and that is easily accomplished by using various FORMATS, startup parameters and/or session attributes.
 

rzr

Member
Yes, for instance while preparing an input file to upload some data into a table.
If you are preparing the input file then you can define the format for your date fields.
You never know which format to use untill you try a test run.
If you are receiving the file from another source, agree with them on a predefined format and then code your logic to read this format and store it back to your date field.
 
Top