View previous topic :: View next topic
|
Author |
Message |
vijayakumar_vc
New User
Joined: 14 Mar 2005 Posts: 2
|
|
|
|
hello friends
please give cobol coding tips for calculating age from
the given date of birth. |
|
Back to top |
|
|
ankyhunk
Moderator
Joined: 05 May 2005 Posts: 98 Location: Navi Mumbai, India
|
|
|
|
You can accept the date of birth from user into a variable using ACCEPT keyword in YYYYMMDD format. Then you can obtain system date using CURRENT-DATE function & move the value to a variable of PIC 9(08). The difference will give you the age in years, months & days. |
|
Back to top |
|
|
ashutosh719
New User
Joined: 06 Apr 2005 Posts: 12
|
|
|
|
OR use Cobol's Intrinsic functions directly...Integer-of-day etc... |
|
Back to top |
|
|
kvivek
New User
Joined: 09 May 2005 Posts: 51 Location: Singapore
|
|
|
|
Hi Vijay,
You could use the following SQL
SELECT CURRENT_DATE - WS-DOB FROM SYSIBM.SYSDUMMY1
which returns the exact number of years, months and days. It also take care of Leap year and the difference in number of days of each month.
Regards,
Vivek |
|
Back to top |
|
|
|