IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Comparing dates in different formats


IBM Mainframe Forums -> SYNCSORT
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
migusd

New User


Joined: 08 Aug 2014
Posts: 44
Location: USA

PostPosted: Sat Nov 18, 2017 3:02 am
Reply with quote

Hello guys,
I just haven't understand how to manage dates in SYNCSORT
Can someone help me understand it ?
I am comparing a date in the record with yesterday's date in the system
If they are different I need the record in the output file and set RC=4

So here is the code
Code:

  INREC BUILD=(FEMA,COM,HDAT,BLK,HTIM,BLK,DATE1(/)-1)                 
  SORT FIELDS=COPY,STOPAFT=1                                           
  OUTFIL INCLUDE=(HDAT,LT,25,10,CH),BUILD=(1,24),VTOF,                 
  NULLOFL=RC0                                                         
DATA DICTIONARY SYMBOLS SUBSTITUTED :                                 
INREC BUILD=(1,4,C',',6,10,C' ',17,8,C' ',DATE1(/)-1)                 
SORT FIELDS=COPY,STOPAFT=1                                             
OUTFIL INCLUDE=(6,10,CH,LT,25,10,CH),BUILD=(1,34),VTOF,NULLOFL=RC4     


So, I couldn't get the desired results. I force the output including both dates.
here is the output file
Code:

FEMA,11/13/2017 20:21:232017/11/16


So the comparing failed because of the date format being different.
I was looking at the manual and I saw Y2W meaning 2 digits for years.
So I tried Y4W. I believe it accepted it. but not Y4W-1
Code:

INREC BUILD=(1,4,C',',6,10,C' ',17,8,Y4W(/)-1)
                                           * 


So, how can I get yesterday's date in MM/DD/YYYY so I can compare it?
Also, is that the correct way of forcing RC=4 when condition is met?

Thank you
Back to top
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2011
Location: USA

PostPosted: Tue Nov 21, 2017 12:10 am
Reply with quote

Y4W is the date FORMAT supported by SORT.
It cannot be used instead of date FUNCTION.

RTFM, please
Back to top
View user's profile Send private message
migusd

New User


Joined: 08 Aug 2014
Posts: 44
Location: USA

PostPosted: Tue Nov 21, 2017 12:23 am
Reply with quote

thanks Sergey,
I have solved my issue
I have a different issue now that I will soon post.
Thank you for your response
Back to top
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2011
Location: USA

PostPosted: Tue Nov 21, 2017 12:33 am
Reply with quote

The easiest way to match date formats is, - to reformat the input field in accordance with the used DATE function, and then to compare two fields with the same format.

Correct way to force RC=4 is, parameter NULLOFL=RC4 in OUTREC/OUTFIL statement (to indicate that the corresponding file is empty)
Back to top
View user's profile Send private message
migusd

New User


Joined: 08 Aug 2014
Posts: 44
Location: USA

PostPosted: Tue Nov 21, 2017 3:28 am
Reply with quote

thanks Sergey.
I have not been able to get RC=4 when the output file is empty.
see my latest post
Thank you
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> SYNCSORT

 


Similar Topics
Topic Forum Replies
No new posts Amount of days between two dates PL/I & Assembler 8
No new posts Comparing Header and Trailer. DFSORT/ICETOOL 7
No new posts Training on numeric fields data formats SYNCSORT 12
No new posts Dates compare on specific dates using... DFSORT/ICETOOL 2
No new posts Comparing Signed Packed decimal and p... SYNCSORT 2
Search our Forums:

Back to Top