Approach to export dates in different formats (e.g. YYYY.MM.DD)

Good day,

In this case I am trying to use a straight-forward "export xx_table" command (rather than to use a put for each field) but make all dates use a specific format.
I have found some work arounds but I assume there is a better way to do it.

It has been a while and can't remember if there is a straight-forward method.

The first issue is the YYYY, a session startup parameter can handle it but let's say, it is not in use (e.g. programs only use "yy")
Also, using century offset works to force YYYY during export but is a mmmmmeh approach (and only partial).

Then, comes the DMY vs MDY vs YMD... which can also be done with session startup parameters or change during the session but say... that is not the case.

Then comes the need to export using "." as separator instead of "/".

All these can be handled and are allowed in "format definition" of a variable or field but export ignores the field formatting and Progress does not allow defining a table field (or variable) as "DD.MM.YYYY" anyway (e.g. as in excel).

So, the question is, is there any SIMPLE way to specific format for all dates being exported without having to format: 1)name each field being exported, 2)having to use another field instead?

Say my session is -mdy using YY....
my date fields are defined as 99/99/99 in format...

I have table with several date fields and they are formatted as 99/99/99. Say we have a date 01/31/20 (Jan 31 2020). What is the SIMPLEST approach to do a straight-forward export using DD.MM.YYYY format?
I am trying to see if I can so an "export xx_table" (rather than naming each field in the export or using text() command, or using another variable and logic to format it to replace it in the export?

for each customer no-lock:
export xx_customer delimiter ",".
/*how to get all dates show in "DD.MM.YYYY" format for this table?*/


If you want to do funky things with date formats that the standard EXPORT does not support then you get to write your own formatting routine.

One way to approach it would be to write a function to return your special format as a string. Something like:

function myDate returns character ( d as date ):
  return( substitute( "&1.&2.&3", string( day( d ), "99" ), string( month( d ), "99" ), string( year( d ), "9999" )).

output to value( "mydate.txt" ).
export myDate( today ).
output close.
Thank for the code Tom.

I was trying to... 1)avoid having to call each field and 2)resolve this using a straight-forward "export xx_table" (rather than calling individual fields, replacing through functions or using variables in their place or resorting to "put" command).

One other thing I was to avoid having this date exported and wrapped in double quotes, as export would do so with any character field or variable.


It's funny how new requirements pop up once there is some code available to test ;)

Sorry, but EXPORT isn't going to support your requirements in the ways that you are asking it to. There are no secret tricks that will make it do so.


Thanks for that. But don't get too carried away - I make mistakes and I am lucky enough to have plenty of people here to correct me when I do. That's the beauty of using public forums.