converting date to a defined format

sreekuax

Member
I need to prepare a data file in which there is a condition :
All date values need to be in the YEAR MONTH DAY order – the year is represented as a 4 digit number followed by the month as a two digit number followed by the day as a two digit number. These values need to be zero padded; i.e. a sign le value is prefixed with a zero (April, 7th, 2010 is represented as 20100407)

say if pt_added = 04/07/10

then as per the above format how can we use progress(I mean the code to get this done)

ideas accepted :-)
 
Procedure that you pass ur date into

Run CovertDateToString(dtDateField)

Then in there build up ur string as needed
Def var intyear format 9999.
Def var intMonth format 99.
Def var intDay format 99.
Def var chrString

intYear = year(inputDate).
intMonth = month(inputDate).
inDay= day(inputDate).
chrString = string(intYear + intMonth + intDay).

return chrString
 
In sufficiently modern versions of Progress, there is an ISO-DATE function which will give you the right layout. Wrap that with a REPLACE to get rid of the separators and you are all done in one line.
 
Back
Top