View previous topic :: View next topic
|
Author |
Message |
amandeep
New User
Joined: 05 Mar 2010 Posts: 2 Location: India
|
|
|
|
Hi All,
I need to calculate 24 number of months old date from current gregorian /julian date. Can anybody help? |
|
Back to top |
|
|
sbprem1
New User
Joined: 05 Mar 2010 Posts: 5 Location: Chennai
|
|
|
|
Well, you can use DB2 built-in functions as follows:
SET :DATEHV = ADD_MONTHS('2000-2-28', 4);
SET :ADD_MONTH = ADD_MONTHS(:DATE,3); |
|
Back to top |
|
|
amandeep
New User
Joined: 05 Mar 2010 Posts: 2 Location: India
|
|
|
|
Sorry I forgot to mention that I need this in cobol , I am not using DB2 |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
What, exactly, are you having trouble with? If you don't know how to do date calculations, you probably should go back to whoever taught you COBOL and ask for a refund since IF and SUBTRACT are both basic COBOL statements. So is getting the current date. |
|
Back to top |
|
|
Anuj Dhawan
Superior Member
Joined: 22 Apr 2006 Posts: 6250 Location: Mumbai, India
|
|
|
|
To be honest, I just don't understand the question? What is being asked, after all?
Quote: |
calculate 24 number of months old date from current gregorian /julian date |
what does "24 number of months" mean? There are only 12 month sI know of! |
|
Back to top |
|
|
Craq Giegerich
Senior Member
Joined: 19 May 2007 Posts: 1512 Location: Virginia, USA
|
|
|
|
What about partial months? |
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10873 Location: italy
|
|
|
|
OK i' ll bite!
why not simply subtract 2 from the years part
yyyymmdd - 24 months = yyyymmdd - 2 years |
|
Back to top |
|
|
|