|
View previous topic :: View next topic
|
| Author |
Message |
itclark
New User
Joined: 10 Nov 2009 Posts: 3 Location: Edinburgh
|
|
|
|
I need to include current date minus 7 days in YY/MM/DD format in my output records.
I can use DATE1(/)-7 to get the correct date with 4 char year 2009/11/03
I can use DATE=(YMD/) to get current date with 2 char year 09/11/10, but I can't see a way to get this format for a date in the past.
Thanks, Ian |
|
| Back to top |
|
 |
Frank Yaeger
DFSORT Developer

Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
| Quote: |
| I can use DATE1(/)-7 to get the correct date with 4 char year 2009/11/03 |
Use DATE1(/)-7 to get 'ccyy/mm/dd' - then rebuild it as 'yy/mm/dd'. For example:
| Code: |
OPTION COPY
INREC IFTHEN=(WHEN=INIT,BUILD=(1,80,81:DATE1(/)-7)),
IFTHEN=(WHEN=INIT,BUILD=(1,80,81:83,8))
|
|
|
| Back to top |
|
 |
itclark
New User
Joined: 10 Nov 2009 Posts: 3 Location: Edinburgh
|
|
|
|
Thanks for that Frank.
I wasn't specific enough with my original query as I only need to include the date on some of the output records, but I have used your suggestion to get the following which works perfectly.
| Code: |
INREC IFTHEN=(WHEN=(5,7,CH,EQ,C'GCMIGDE'),
BUILD=(1,21,DATE1(/)-7,30,6))
OUTREC IFTHEN=(WHEN=(5,7,CH,EQ,C'GCMIGDE'),
BUILD=(1,21,22:24,43))
|
Regards, Ian |
|
| Back to top |
|
 |
Frank Yaeger
DFSORT Developer

Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
Note that you don't need an INREC and OUTREC statement to do this. You can do it with just one of them. For example:
| Code: |
OPTION COPY
INREC IFTHEN=(WHEN=(5,7,CH,EQ,C'GCMIGDE'),
BUILD=(1,21,DATE1(/)-7,30,6),HIT=NEXT),
IFTHEN=(WHEN=ANY,BUILD=(1,21,22:24,43))
|
|
|
| Back to top |
|
 |
itclark
New User
Joined: 10 Nov 2009 Posts: 3 Location: Edinburgh
|
|
|
|
| Thanks Frank - that's perfect. |
|
| Back to top |
|
 |
|
|
 |
All times are GMT + 6 Hours |
|