View previous topic :: View next topic
|
Author |
Message |
santohsks1987 Warnings : 1 New User
Joined: 29 Dec 2010 Posts: 31 Location: Mumbai
|
|
|
|
Hi,
I need to do date calculations in cobol and Db2.
Some of the operations are, To add 5 months to particular date, To subtract/add days or months or years from a particular date, to find the first day of next month, difference of two dates.
Are there any intrinsic functions in cobol using which i can do all the operations directly? If there is any manual for the same, Please share the link.
how to do the same things in DB2? |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
Look up intrinsic functions in your Cobol manual first, review against your requirements and then ask if there is anything you don't understand or is necessary but not supplied.
I can't believe there is a function for first day of next month, but if there is, surely you can code it better yourself? Subtracting years is pretty easy. To subtract months it is important that you understand what you mean by a month (calendar month, average no of days, what?) and then some solutions are easier than others. |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
Depending upon which version of COBOL you are using, there is a link to manuals at the top of THIS page. Most sites have long-established date manipulation routines and you need to talk to your co-workers, team leader, or site support group to find out what your site uses.
COBOL has no intrinsic functions to do what you want. You can convert dates into integers, then add (or subtract) the appropriate number of days, then convert back into a date using the intrinsic functions -- but you cannot just "add five months" to a date in COBOL using them. |
|
Back to top |
|
|
santohsks1987 Warnings : 1 New User
Joined: 29 Dec 2010 Posts: 31 Location: Mumbai
|
|
|
|
Thank You Robert for the info.
But is there any utility in DB2 for the same.
If you have any material please share the link. |
|
Back to top |
|
|
Nic Clouston
Global Moderator
Joined: 10 May 2007 Posts: 2455 Location: Hampshire, UK
|
|
|
|
Why don't you just look for the manuals yourself? There are links all over the forum and there is google. |
|
Back to top |
|
|
Phrzby Phil
Senior Member
Joined: 31 Oct 2006 Posts: 1042 Location: Richmond, Virginia
|
|
|
|
But he was only told to look in COBOL manuals for COBOL info.
No one said to extrapolate this brilliant idea to DB2. |
|
Back to top |
|
|
Mickeydusaor
Active User
Joined: 24 May 2006 Posts: 258 Location: Salem, Oregon
|
|
|
|
DB2 can do this for you..... |
|
Back to top |
|
|
Kjeld
Active User
Joined: 15 Dec 2009 Posts: 365 Location: Denmark
|
|
|
|
It just requires reviewing the DB2 SQL manuals instead for date computations... |
|
Back to top |
|
|
Aelbery Lee
New User
Joined: 29 Jun 2011 Posts: 1 Location: China
|
|
|
|
Please try ADD-DURATION, FIND-DURATION, SUBTRACT-DURATION, whether your cobol version support these functions. |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
Aelbery Lee, those functions are NOT part of standard Enterprise COBOL. Either they are functions for a non-mainframe version of COBOL (in which case, why mention them at all since this is a MAINFRAME forum), or they are specific to your site and unless someone is working at your site the functions will be useless. |
|
Back to top |
|
|
Anuj Dhawan
Superior Member
Joined: 22 Apr 2006 Posts: 6250 Location: Mumbai, India
|
|
Back to top |
|
|
|