Focal Point
Date math and formatting

This topic can be found at:
https://forums.informationbuilders.com/eve/forums/a/tpc/f/7971057331/m/3051087331

June 10, 2004, 08:11 PM
Nightowl
Date math and formatting
I need to calculate the first date of the current month and the first date of the previous month. I also need to display the previous month and year in the header. I have the first date of each month working but I would like the date in the header to be mixed case.
Here is my code:
-SET &START_DATE = &YYMD;
-SET &END_DATE = &YYMD;
-SET &DAY = EDIT(&YYMD, '$$$$$$99');
-SET &END_DATE = DATEADD(&END_DATE,'D',-&DAY+1);
-SET &START_DATE = DATEADD(DATECVT(&END_DATE, 'I8YYMD', 'YYMD'),'M',-1);
-SET &START_DATE = DATECVT(&START_DATE, 'YYMD', 'I8YYMD');
-SET &START_DISP = CHGDAT('YYMD', 'MYYX', &START_DATE, 'A17');

The &START_DISP uses MYYX to get long months but they come out in upper case only.
Is this the best way to do this type of calculation? I need it in a seperate fex that other fexes can include.
Thanks
June 10, 2004, 08:30 PM
<Pietro De Santis>
Use the LCWORD function:



-SET &RUN_DATEX = CHGDAT('YYMD', 'MXDYY', &YYMD, 'A17');
-SET &RUN_DATE = LCWORD(&RUN_DATEX.LENGTH, &RUN_DATEX, 'A17');

This message has been edited. Last edited by: <Mabel>,
June 10, 2004, 08:36 PM
Nightowl
Way Cool ! Exactly what I was looking for.
Thanks.
June 11, 2004, 08:15 PM
David Sibert
Another way is as follows:

TRD/I8 = &TRDATE ;
TRDTA/I8YYMD = TRD ;
TRDT/YYMD=TRDTA;
TRDTS/HDMtYY=HDTTM(TRDT,8,'HDMtYY');

This will give 11 Jun 2004 in TRDTS.

David