Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Difference betwee two dates in Months

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
View previous topic :: :: View next topic  
Author Message
simha_it

New User


Joined: 05 May 2005
Posts: 30

PostPosted: Mon Apr 12, 2010 4:39 pm    Post subject: Difference betwee two dates in Months
Reply with quote

Hi,
Could you please tell me a logic to find out the number months between two dates.

for ex: Date1 - 31-12-2009, Date 31-03-2010. the difference in months are: 3.

Date1 - 31-12-2009, Date 18-04-2010. the difference in months are: 4.
Note: if the date crossed 15th, then that will consider it as 1 month. Here date is 18th. So 3+1 = 4

Please assist me.

Thanks
Simha
Back to top
View user's profile Send private message

Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Mon Apr 12, 2010 9:25 pm    Post subject:
Reply with quote

simha_it,

Sort products do NOT have the ability of calculating the difference between 2 dates.
Back to top
View user's profile Send private message
khannay2k

New User


Joined: 24 Feb 2005
Posts: 28
Location: Bangalore

PostPosted: Tue Apr 13, 2010 12:40 pm    Post subject: Reply to: Difference betwee two dates in Months
Reply with quote

Simha,

You will have to write simple logic to find out the diff.

Capture the year part of date2 in ws-date2-yy, Capture the year part of date1 in ws-date1-yy.
Find the diff b/w these two var
ws-yr-diff = (ws-date2-yy - ws-date1-yy)

Capture the month part of date2 in ws-date2-mm, Capture the year part of date1 in ws-date1-mm.
Find the diff b/w these two var
ws-mm-diff = (ws-date2-mm - ws-date1-mm)

Capture the day part of date2 in ws-date2-dd.
If
ws-date2-dd < 16
ws-diffmm = ws-yr-diff *12 + ws-mm-diff -1
else
ws-diffmm = ws-yr-diff *12 + ws-mm-diff

Hope this helps.

khanna
Back to top
View user's profile Send private message
khannay2k

New User


Joined: 24 Feb 2005
Posts: 28
Location: Bangalore

PostPosted: Tue Apr 13, 2010 12:48 pm    Post subject: Reply to: Difference betwee two dates in Months
Reply with quote

Simha,

I am sorry slight change in the code, month part of date2 can be < month part of date1, so

Capture the year part of date2 in ws-date2-yy, Capture the year part of date1 in ws-date1-yy.
Find the diff b/w these two var
ws-yr-diff = (ws-date2-yy - ws-date1-yy)

Capture the month part of date2 in ws-date2-mm, Capture the year part of date1 in ws-date1-mm.

ws-mm-diff = (ws-date2-mm + ws-yr-diff * 12 - ws-date1-mm)

Capture the day part of date2 in ws-date2-dd.
If
ws-date2-dd < 16
ws-mm-diff = ws-mm-diff - 1

Hope this helps.

khanna
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Difference between TWALENG and TWASIZE Arunkumar Chandrasekaran CICS 3 Tue Jan 03, 2017 12:57 pm
No new posts Sticky: difference between ... DUMMY ... and ... enrico-sorichetti JCL & VSAM 0 Mon Oct 17, 2016 4:31 pm
No new posts Difference space showed for TS and it... autobox DB2 1 Thu Apr 14, 2016 1:07 pm
No new posts Difference Between CICS WebSupport an... sachinji84 CICS 1 Mon Mar 07, 2016 7:25 pm
No new posts Difference between -180 and -181 with... deepak_shrivastava DB2 4 Wed Jan 06, 2016 10:00 am


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us