Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
Finding the number of years from two dates

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
View previous topic :: :: View next topic  
Author Message
vin12pr
Warnings : 1

New User


Joined: 14 Jun 2006
Posts: 56

PostPosted: Mon Dec 11, 2006 5:43 pm    Post subject: Finding the number of years from two dates
Reply with quote

Can you please help me in finding the number of years from two dates which are in the format dd.mm.yyyy. i.e. , no of years between two dates.
Back to top
View user's profile Send private message

guptae

Moderator


Joined: 14 Oct 2005
Posts: 1187
Location: Bangalore,India

PostPosted: Mon Dec 11, 2006 6:17 pm    Post subject:
Reply with quote

Hi there,

I think you can use DATEDF function for this.


DATEDF ? Calculate Date Difference
This program calculates the number of days, weeks, and months between the two given dates. The one argument is the following array. BEGIN-DATE and END-DATE must be specified by the calling program. The remaining fields are calculated by this routine. The four RESULT fields are the count for each. BEGIN-WEEK-DAY and END-WEEK-DAY are 1 = Sunday through 7 = Saturday.
01 DATE-CALCULATION.
03 BEGIN-DATE.
05 BD-CENT PIC S99 USAGE COMP-5.
05 BD-YEAR PIC S99 USAGE COMP-5.
05 BD-MNTH PIC S99 USAGE COMP-5.
05 BD-DAY PIC S99 USAGE COMP-5.
03 END-DATE.
05 ED-CENT PIC S99 USAGE COMP-5.
05 ED-YEAR PIC S99 USAGE COMP-5.
05 ED-MNTH PIC S99 USAGE COMP-5.
05 ED-DAY PIC S99 USAGE COMP-5.
03 RESULT-DAYS PIC S9999 USAGE COMP-5.
03 RESULT-WEEKS PIC S9999 USAGE COMP-5 OCCURS 7 TIMES.
03 RESULT-MONTHS PIC S9999 USAGE COMP-5.
03 RESULT-YEARS PIC S9999 USAGE COMP-5.
03 BEGIN-WEEK-DAY PIC S9999 USAGE COMP-5.
03 END-WEEK-DAY PIC S9999 USAGE COMP-5.
Hope it will helpful.
Back to top
View user's profile Send private message
guptae

Moderator


Joined: 14 Oct 2005
Posts: 1187
Location: Bangalore,India

PostPosted: Mon Dec 11, 2006 6:25 pm    Post subject:
Reply with quote

Hi there,

In my prev post i mentioned the COBOl function to do this.
For DB2

Code:
Select Year ( Date(end_date) - Date(begin_date))
From Table1;
Back to top
View user's profile Send private message
vin12pr
Warnings : 1

New User


Joined: 14 Jun 2006
Posts: 56

PostPosted: Mon Dec 11, 2006 6:37 pm    Post subject: Re: Finding the number of years from two dates
Reply with quote

Hi,

Thanks Ekta for ur kind reply.....Does that cobol caluculation caluculates the difference in the number of years between the 2 dates?

I guess this is for number of days or months betweent the 2 dates??

Can you please expand a bit

Thanks,
Vinay
Back to top
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3158
Location: Tucson AZ

PostPosted: Mon Dec 11, 2006 6:39 pm    Post subject:
Reply with quote

If you have the two dates, what's wrong with just subtracting the years from each other?
Back to top
View user's profile Send private message
guptae

Moderator


Joined: 14 Oct 2005
Posts: 1187
Location: Bangalore,India

PostPosted: Mon Dec 11, 2006 6:53 pm    Post subject:
Reply with quote

Hi vin12pr,

By this u can get number of month between the two given dates then u can calculate number of years also.
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 -> DB2 All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts LMINIT problem - not finding DDNAME Danielle.Filteau CLIST & REXX 7 Tue Sep 19, 2017 9:57 pm
No new posts Finding IMS resource blocker after se... Hooman24 IMS DB/DC 1 Wed Aug 16, 2017 9:17 pm
No new posts Profile changed to NUMBER ON STD (fro... Martylin TSO/ISPF 1 Thu Aug 03, 2017 9:14 am
No new posts Allianz Technology - Mainframe 3+ Yea... sooraj184 Mainframe Jobs 0 Mon Jul 31, 2017 2:17 pm
No new posts finding delayed job/s in OPC jzhardy IBM Tools 0 Mon May 29, 2017 9:04 am

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us