View previous topic :: View next topic
|
Author |
Message |
srinathds83
New User
Joined: 17 Jul 2007 Posts: 41 Location: pune
|
|
|
|
Hi,
I have requirement to subtract the two months from Current Date and print it in YYMMDD format.
Thanks
Sri |
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10888 Location: italy
|
|
|
|
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 |
|
|
Nic Clouston
Global Moderator
Joined: 10 May 2007 Posts: 2454 Location: Hampshire, UK
|
|
|
|
Is it safe to assume that you are using Syncsort? |
|
Back to top |
|
|
srinathds83
New User
Joined: 17 Jul 2007 Posts: 41 Location: pune
|
|
|
|
Nic Clouston wrote: |
Is it safe to assume that you are using Syncsort? |
Yes we are using the Syncsort Utility only. |
|
Back to top |
|
|
srinathds83
New User
Joined: 17 Jul 2007 Posts: 41 Location: pune
|
|
|
|
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 |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10888 Location: italy
|
|
|
|
where are You facing problems ?
the algorithm/logic
the coding |
|
Back to top |
|
|
srinathds83
New User
Joined: 17 Jul 2007 Posts: 41 Location: pune
|
|
|
|
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 |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
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 |
|
|
srinathds83
New User
Joined: 17 Jul 2007 Posts: 41 Location: pune
|
|
|
|
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 |
|
|
srinathds83
New User
Joined: 17 Jul 2007 Posts: 41 Location: pune
|
|
|
|
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 |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
Can you paste from your SyncSort documentation where SUBMONS is supported? |
|
Back to top |
|
|
srinathds83
New User
Joined: 17 Jul 2007 Posts: 41 Location: pune
|
|
|
|
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 |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10888 Location: italy
|
|
|
|
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 |
|
|
|