PDA

View Full Version : process file by YYYYMM using date defined as L in DDS



Absolutely_Nobody
01-13-2003, 08:32 AM
What is the best way to process a file for all records for a specific year and month when the date is defined in the file is L ( date data type ) ? Will I need to create a logical over the PF to substring the YYYY and MM parts of the key to the logical ? Then, SETLL/READE all of the records matching YYYY/MM in the key in the program ? Is there an easier way ?

B.Morris
01-13-2003, 09:08 AM
Richard Rothe wrote: > > What is the best way to process a file for all records for a specific year and month when the date is defined in the file is L ( date data type ) ? > > Will I need to create a logical over the PF to substring the YYYY and MM parts of the key to the logical ? Then, SETLL/READE all of the records matching YYYY/MM in the key in the program ? > > Is there an easier way ? Don't know if it's easier, but if you have the date as a key, you could SETLL to yyyy/mm/01 and then calculate the beginning of the next month: startdate adddur 1:*month nextmonth Then use READ, not READE, and exit your loop if thedate >= nextmonth Another way, you could use OPNQRYF, where you build up the QRYSLT string dynamically: OPNQRYF FILE((myfile)) QRYSLT('(FLD1 *GE ''2003-01-01'') *AND (FLD1 *LE ''2003-01-31'')') To get the last day of the month, do this: startdate adddur 1:*month nextmonth nextmonth subdur 1:*day endmonth