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

JCL SORT - Subtract 2 Months from Current Date


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

New User


Joined: 17 Jul 2007
Posts: 41
Location: pune

PostPosted: Mon May 12, 2014 12:57 pm
Reply with quote

Hi,

I have requirement to subtract the two months from Current Date and print it in YYMMDD format.

Thanks
Sri
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10886
Location: italy

PostPosted: Mon May 12, 2014 1:21 pm
Reply with quote

Quote:
I have requirement to subtract the two months from Current Date and print it in YYMMDD format.


did anybody consider what should happen when the current date will be APRIL, 30

usually this kind of task is carried on by the DATE handling function/subroutines normally available in any decent organization
( such functions are usually tailored to the business/legal standards/rules in place )
Back to top
View user's profile Send private message
Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 2454
Location: Hampshire, UK

PostPosted: Mon May 12, 2014 1:46 pm
Reply with quote

Is it safe to assume that you are using Syncsort?
Back to top
View user's profile Send private message
srinathds83

New User


Joined: 17 Jul 2007
Posts: 41
Location: pune

PostPosted: Mon May 12, 2014 2:02 pm
Reply with quote

Nic Clouston wrote:
Is it safe to assume that you are using Syncsort?


Yes we are using the Syncsort Utility only.
Back to top
View user's profile Send private message
srinathds83

New User


Joined: 17 Jul 2007
Posts: 41
Location: pune

PostPosted: Mon May 12, 2014 2:52 pm
Reply with quote

Hi,

Below sort card works with the number of Days.
Code:

//SYSIN DD *                                   
   OPTION COPY                                 
   INCLUDE COND=(1,6,Y2T,EQ,Y'DATE1'-61)       
/*                                             


But i want to subtract 2 months directly. Above sort card is not correct for the Feb Month calculation and for July and August calculation.

I am looking for solution where it can take leap year in to account as well during month subtraction.

Thanks
Sri
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10886
Location: italy

PostPosted: Mon May 12, 2014 3:05 pm
Reply with quote

where are You facing problems ?
the algorithm/logic
the coding
Back to top
View user's profile Send private message
srinathds83

New User


Joined: 17 Jul 2007
Posts: 41
Location: pune

PostPosted: Tue May 13, 2014 10:20 am
Reply with quote

Hi,

I was trying to use SUBMONS but it can't be used with Y'DATE1'. Can anyone help me to subtract the Months directly from the current date.

Code:

//SYSIN DD *                                   
   OPTION COPY                                 
   INCLUDE COND=(1,6,Y2T,EQ,Y'DATE1'-61)       
/*                                     


As Above card subtract the number of days but that is not the smarter way as i have to subtract two months. suppose it is 1st april then the number of days should be subtracted 59 or 60(if leap year).

Can anyone provide the solution where sort manages own its own and subtract the exact 2 months from Current date.

Thanks.
Sri
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Tue May 13, 2014 12:03 pm
Reply with quote

Does your SORT product allow you Julian to Gregorian conversion? If so, convert it (which auto-magically know about leap-years) and then just test on the month.
Back to top
View user's profile Send private message
srinathds83

New User


Joined: 17 Jul 2007
Posts: 41
Location: pune

PostPosted: Tue May 13, 2014 2:29 pm
Reply with quote

Bill Woodger wrote:
Does your SORT product allow you Julian to Gregorian conversion? If so, convert it (which auto-magically know about leap-years) and then just test on the month.


i want the Current date in YYMMDD format from which i have to deduct 2 months and then compare it with my Input date field in file (which is also in YYMMDD) format.
Back to top
View user's profile Send private message
srinathds83

New User


Joined: 17 Jul 2007
Posts: 41
Location: pune

PostPosted: Tue May 13, 2014 3:47 pm
Reply with quote

Hi,

I tried using the below sort card where i am trying to subtract from date in file.

Code:

SYSIN :                                         
   OPTION COPY                                 
   OUTREC BUILD=(1,8,Y4T,SUBMONS,+3,TOGREG=Y4T)
                     *                         
WER161B  ALTERNATE PARM USED                   
WER268A  OUTREC STATEMENT  : SYNTAX ERROR       
WER211B  SYNCSMF  CALLED BY SYNCSORT; RC=0000   


Could anyone help on this. If this work then i can try to subtract it from current date instead of using the date from input file.
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Tue May 13, 2014 4:11 pm
Reply with quote

Can you paste from your SyncSort documentation where SUBMONS is supported?
Back to top
View user's profile Send private message
srinathds83

New User


Joined: 17 Jul 2007
Posts: 41
Location: pune

PostPosted: Tue May 13, 2014 5:26 pm
Reply with quote

Bill Woodger wrote:
Can you paste from your SyncSort documentation where SUBMONS is supported?


Below is the refrence i took it from the IBM Site:

SUBDAYS, SUBMONS or SUBYEARS can be used to subtract days,
months or years from a date field. As a simple example, you could use the
following to subtract 3 months from a P'dddyy' date and produce the
resulting P'ccyyddd' date:
OUTREC BUILD=(1,8,Y4T,SUBMONS,+3,TOGREG=Y4T)

Site suggests that it will work whereas i am getting syntax error for same sort card.
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10886
Location: italy

PostPosted: Tue May 13, 2014 5:42 pm
Reply with quote

Quote:
Yes we are using the Syncsort Utility only.


Quote:
Below is the refrence i took it from the IBM Site:
...
...
...


Code:
WER161B  ALTERNATE PARM USED   


since You are using SYNCSORT You should read SYNCSORT manuals not the DFSORT manuals.
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 JCL sort to compare dates in two file... DFSORT/ICETOOL 2
No new posts Is this possible via sort (in one pass)? SYNCSORT 4
No new posts GDG generation name to GDG Base name ... DFSORT/ICETOOL 3
No new posts SORT on detail record, then repeat he... DFSORT/ICETOOL 3
No new posts Date format correction using dfsort DFSORT/ICETOOL 3
Search our Forums:

Back to Top