View previous topic :: View next topic
|
Author |
Message |
Chidane
New User
Joined: 25 Nov 2021 Posts: 19 Location: India
|
|
|
|
Hi Team,
Please help me to solve this.
I have a flat file with record legth 30 bytes having 2 char User ID and 26 char Timestamp. I would like to filter and get the records that has Timestamp value for last 7 days from current date.
Code: |
Input file
AB 2012-10-27-12.45.32.791914
CD 2024-04-27-12.45.32.791914
VC 2024-04-19-12.45.32.791914
DF 2024-04-25-12.45.32.791914
ZY 2003-09-25-12.45.32.791914 |
If I am executing the job with SORT step today 2024-04-28, Output should be
Code: |
CD 2024-04-27-12.45.32.791914
DF 2024-04-25-12.45.32.791914 |
Is it possible to acheive this using DFSORT step.
Thanks
CD |
|
Back to top |
|
|
Joerg.Findeisen
Senior Member
Joined: 15 Aug 2015 Posts: 1329 Location: Bamberg, Germany
|
|
|
|
Code: |
OPTION COPY
INREC OVERLAY=(31:5,10,UFF,TO=ZD,LENGTH=8,31:31,8,Y4T,AGE=YD)
OUTFIL FNAMES=(SORTOUT),
INCLUDE=(31,7,ZD,LT,+7),
REMOVECC,
BUILD=(1,30)
END |
To deal with the complete timestamp, you will have to add extra logic. |
|
Back to top |
|
|
Joerg.Findeisen
Senior Member
Joined: 15 Aug 2015 Posts: 1329 Location: Bamberg, Germany
|
|
|
|
The very short option:
Code: |
OPTION COPY
INCLUDE COND=(5,10,CH,GE,DATE1(-)-7)
END |
|
|
Back to top |
|
|
Chidane
New User
Joined: 25 Nov 2021 Posts: 19 Location: India
|
|
|
|
Thanks Joerg. Both the SORT card works like a charm.
If I want to include HEADER and TRAILER from input data as is to output, what changes I need to make in the second SORT card
Input file
Code: |
HEADER 2024-05-03
AB 2012-10-27-12.45.32.791914
CD 2024-04-27-12.45.32.791914
VC 2024-04-19-12.45.32.791914
DF 2024-04-25-12.45.32.791914
ZY 2003-09-25-12.45.32.791914
9TRAILER |
|
|
Back to top |
|
|
Joerg.Findeisen
Senior Member
Joined: 15 Aug 2015 Posts: 1329 Location: Bamberg, Germany
|
|
|
|
Just extend the INCLUDE statement, or use HEADER/TRAILER parameters in the OUTFIL statement. It's up to you. |
|
Back to top |
|
|
Chidane
New User
Joined: 25 Nov 2021 Posts: 19 Location: India
|
|
|
|
Thanks Joerg. This works like a charm |
|
Back to top |
|
|
|