# How to OMIT Records older than the current date

Author Message
kregen

New User

Joined: 16 Mar 2006
Posts: 21

Posted: Thu Jan 27, 2022 12:58 pm

Hello together,
I have the following problem.

During the processing of a file, all records older than the current date - 1 year should be omitted.

The date in the record for comparison is packed (PD) and has the following structure: 0(n)YYDDD
n = 0 = 19 century
n = 1 = 20 century

Data example
 Code: .p.§ 0907 073C ---- .r.. 0930 090C ---- .... 0012 160C ---- ...§ 0137 112C ---- .q.. 0923 082C ---- ...< 0004 117C ---- ...% 0006 102C ...% 0236 115C ---- ...* 0035 103C ---- .... 0012 181C ---- .... 0121 177C ---- .... 0000 102C ---- .r.. 0933 092C ---- ...< 0124 198C ----

What options do I have to skip the unnecessary records.

I am very interested to see how the solution looks like.

Thanks a lot for the support.

Greetings / Regards
kregen
Joerg.Findeisen

Senior Member

Joined: 15 Aug 2015
Posts: 1138
Location: Bamberg, Germany

Posted: Thu Jan 27, 2022 7:20 pm

Look up the following in the manual:
 Code: DATE3P-d

you will need to adjust the length of the input field to match the format of DATE3P, then you can easily compare with what's requested.

Let's see what you have tried so far as well, please.
kregen

New User

Joined: 16 Mar 2006
Posts: 21

Posted: Thu Jan 27, 2022 9:12 pm

HelloJerg,
if you an now tell me how i can calculate the comparative value from the input data, then the solution would be perfect.

how can i convert the input 0(n)YYDDD to YYYYDDD in DFSORT?

 Code: in other language i use: Field + 1900000 = YYYYDDD

is this possible with DFSORT?

regards
kregen
sergeyken

Senior Member

Joined: 29 Apr 2008
Posts: 1884
Location: USA

Posted: Thu Jan 27, 2022 10:58 pm

kregen wrote:
HelloJerg,
if you an now tell me how i can calculate the comparative value from the input data, then the solution would be perfect.

how can i convert the input 0(n)YYDDD to YYYYDDD in DFSORT?

 Code: in other language i use: Field + 1900000 = YYYYDDD

is this possible with DFSORT?

regards
kregen

How do you plan to deal with the dates of XXI century?

- CENTWIN parameter
- date conversion parameters - Y2P, Y2T, Y2W, ... (+50 more)
sergeyken

Senior Member

Joined: 29 Apr 2008
Posts: 1884
Location: USA

Posted: Fri Jan 28, 2022 12:22 am

FYI:
In SORT the arithmetics with packed decimal are performed (if the field is a correct packed decimal value of four bytes) in the following manner:

Suppose your date is stored in the field as X'00yydddC' = +yyddd
The result would be X'19yydddC', or X'2yyydddC'

Subtraction of one year can be done as follows:
 Code: ...pos,4,PD,SUB,+1000,LENGTH=4,...
But you must take care of leap year's changed day numbers yourself!

Everything about arithmetic operations is described in details in any SORT manual. It would be a good idea to refer to it.
sergeyken

Senior Member

Joined: 29 Apr 2008
Posts: 1884
Location: USA

Posted: Fri Jan 28, 2022 3:08 am

I forgot one important parameter in both cases, to get result in packed decimal as well:

 Code: ...pos,4,PD,SUB,+1000,TO=PD,LENGTH=4,...
sergeyken

Senior Member

Joined: 29 Apr 2008
Posts: 1884
Location: USA

Posted: Fri Jan 28, 2022 3:54 am

 kregen wrote: if you an now tell me how i can calculate the comparative value from the input data, then the solution would be perfect.

A sort of a smart alec question...

 Code: INREC OVERLAY=(81:1,4,PD,ADD,+1900000,TO=PD,LENGTH=4)  SORT FIELDS=COPY  OUTFIL OMIT=(81,4,PD,LT,&DATE3P-365),         BUILD=(1,80)
Joerg.Findeisen

Senior Member

Joined: 15 Aug 2015
Posts: 1138
Location: Bamberg, Germany

Posted: Sun Jan 30, 2022 10:50 pm

sergeyken wrote:
 Code: INREC OVERLAY=(81:1,4,PD,ADD,+1900000,TO=PD,LENGTH=4)  SORT FIELDS=COPY  OUTFIL OMIT=(81,4,PD,LT,&DATE3P-365),         BUILD=(1,80)

Kind of this was my first attempt, however your replies made me look up the manual (again). Request can be fulfilled a bit more simple, but basically I would like to see at least one attempt to solve the issue by the TS first.
sergeyken

Senior Member

Joined: 29 Apr 2008
Posts: 1884
Location: USA

 Posted: Mon Jan 31, 2022 12:37 am Arithmetic conversion of the non-standard date value, and date comparison with any current-date function need to be done separately in two different statements (or IFTHEN= which is the same). This is the major limitation of SORT, other updates are less important.
kregen

New User

Joined: 16 Mar 2006
Posts: 21

 Posted: Mon Jan 31, 2022 12:38 pm hello together, thanks to all for the good support. Regards Kai
Joerg.Findeisen

Senior Member

Joined: 15 Aug 2015
Posts: 1138
Location: Bamberg, Germany

 Posted: Mon Jan 31, 2022 1:58 pm Please show what you have tried. I do have two more updates for this case to discuss.
sergeyken

Senior Member

Joined: 29 Apr 2008
Posts: 1884
Location: USA

 Posted: Mon Jan 31, 2022 7:33 pm The date in the input field has proprietary format, as X'0cyydddC', not acceptable as data format by SORT utility. Any date value calculated from the current &DATExxx in SORT has one of standard formats, such as X'yyyydddC' Those two cannot be compared, like "oranges to apples". Arithmetic is needed (as PD format), either X'0cyydddC'+1900000 or X'yyyydddC'-1900000 Arithmetic operation cannot be incorporated neither into INCLUDE/OMIT condition, nor into SYMNAMES dictionary; a separate statement is needed, with extra intermediate field. So, I did not find a more simple solution, though the order of operations can be changed.
Joerg.Findeisen

Senior Member

Joined: 15 Aug 2015
Posts: 1138
Location: Bamberg, Germany

Posted: Mon Jan 31, 2022 9:07 pm

 sergeyken wrote: The date in the input field has proprietary format, as X'0cyydddC', not acceptable as data format by SORT utility.

One of your statements made me look up the manual, and there is the following:
 Code: Y'DATE3'-365
sergeyken

Senior Member

Joined: 29 Apr 2008
Posts: 1884
Location: USA

Posted: Mon Jan 31, 2022 9:38 pm

Joerg.Findeisen wrote:
 sergeyken wrote: The date in the input field has proprietary format, as X'0cyydddC', not acceptable as data format by SORT utility.

One of your statements made me look up the manual, and there is the following:
 Code: Y'DATE3'-365

It produces C'YYDDD' - cannot compare to P'0cyydddC' ...
Joerg.Findeisen

Senior Member

Joined: 15 Aug 2015
Posts: 1138
Location: Bamberg, Germany

Posted: Thu Feb 03, 2022 12:41 pm

 sergeyken wrote: It produces C'YYDDD' - cannot compare to P'0cyydddC' ...

Basically you can, look up Table 29. Permissible Comparisons for Dates in the Manual.
sergeyken

Senior Member

Joined: 29 Apr 2008
Posts: 1884
Location: USA

Posted: Thu Feb 03, 2022 6:23 pm

Joerg.Findeisen wrote:
 sergeyken wrote: It produces C'YYDDD' - cannot compare to P'0cyydddC' ...

Basically you can, look up Table 29. Permissible Comparisons for Dates in the Manual.
Again: the date format P'cyyddd' = X'0cyydddC' is a proprietary one.
None of standard date operations, including date comparison, is applicable to this non-standard value, without its preliminary conversion.
 View Bookmarks All times are GMT + 6 Hours

 Topic Forum Replies Similar Topics Changeman - how can we know the curr... Compuware & Other Tools 2 Need help to append a date&tsp at... DFSORT/ICETOOL 9 Fetch data from programs execute (dat... DB2 3 Use input file with OMIT rcd keys? DFSORT/ICETOOL 15 Join multiple records using splice DFSORT/ICETOOL 5
Search our Forums:

 IBMMainframes.com is not an official and/or affiliated with IBM® in anyway Board Rules | FAQ | Downloads | Wiki | SiteMap | Contact Us