1
votes

Requirement: I need to sort an input file based on Date. The date is in YYYYMMDD format starting at 56th Position in the flat file. Now, the I am trying to write a sort card which writes all the records that have the date(YYYYMMDD) in the past 7 Days.

Example: My job is running on 20181007, it should fetch all the records that have date in between 20181001 to 20181007.

Thanks in advance.

1
Can you provide the sort card you have create so far ? What sort product are you using ? - Hogstrom
One of the issue that you could encounter is if the job is delayed and doesn't run until after midnight (you could then miss out a day if this were a weekly run). Some scheduling packages allow you to pass/substitute the scheduled date rather than the actual run date (say if the date were a parameter or in-stream data). - MikeT
Added to what @MikeT saya, DFsort can accept data via a parameter (JPy, I think) so you could pass your business date via that. However, if you use Syncsort than thiat option may not be availalble. You really should specify your sort product. Also, you have used the JCL tag but, really, this is nthing to do with JCL but sort control statements which are NOT JCL. - NicC

1 Answers

3
votes

In terms of DFSort you can use the following filter to select the current date as a relative value. For instance:

OUTFIL INCLUDE=(56,8,CH,GE,DATE1-7)

There are several definitions for Dates in various formats. I assume that since you are referring to a flat file the date is in a character format and not zoned decimal or other representation.

For DFSort here is a reference to the include statement

Similar constructs exist for other sort products. Without specifics about the product your using this is unfortunately a generic answer.