IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Cobol Date functions


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
santohsks1987
Warnings : 1

New User


Joined: 29 Dec 2010
Posts: 31
Location: Mumbai

PostPosted: Thu Apr 07, 2011 11:10 am
Reply with quote

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
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Thu Apr 07, 2011 11:55 am
Reply with quote

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
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8696
Location: Dubuque, Iowa, USA

PostPosted: Thu Apr 07, 2011 2:58 pm
Reply with quote

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
View user's profile Send private message
santohsks1987
Warnings : 1

New User


Joined: 29 Dec 2010
Posts: 31
Location: Mumbai

PostPosted: Thu Apr 07, 2011 4:32 pm
Reply with quote

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
View user's profile Send private message
Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 2455
Location: Hampshire, UK

PostPosted: Thu Apr 07, 2011 7:00 pm
Reply with quote

Why don't you just look for the manuals yourself? There are links all over the forum and there is google.
Back to top
View user's profile Send private message
Phrzby Phil

Senior Member


Joined: 31 Oct 2006
Posts: 1042
Location: Richmond, Virginia

PostPosted: Thu Apr 07, 2011 7:09 pm
Reply with quote

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
View user's profile Send private message
Mickeydusaor

Active User


Joined: 24 May 2006
Posts: 258
Location: Salem, Oregon

PostPosted: Fri Apr 08, 2011 12:52 am
Reply with quote

DB2 can do this for you.....
Back to top
View user's profile Send private message
Kjeld

Active User


Joined: 15 Dec 2009
Posts: 365
Location: Denmark

PostPosted: Fri Apr 08, 2011 4:27 am
Reply with quote

It just requires reviewing the DB2 SQL manuals instead for date computations...
Back to top
View user's profile Send private message
Aelbery Lee

New User


Joined: 29 Jun 2011
Posts: 1
Location: China

PostPosted: Tue Jul 05, 2011 1:42 pm
Reply with quote

Please try ADD-DURATION, FIND-DURATION, SUBTRACT-DURATION, whether your cobol version support these functions.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8696
Location: Dubuque, Iowa, USA

PostPosted: Tue Jul 05, 2011 3:51 pm
Reply with quote

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
View user's profile Send private message
Anuj Dhawan

Superior Member


Joined: 22 Apr 2006
Posts: 6250
Location: Mumbai, India

PostPosted: Tue Jul 05, 2011 4:12 pm
Reply with quote

santohsks1987,

If you're using IBM Enterprise COBOL for z/OS, You might like to visit these links: publib.boulder.ibm.com/infocenter/wdzinfo/v7r0/index.jsp?topic=/com.ibm.ent.cbl.zos.doc/topics/rlinfidt.htm
www.ibm.com/developerworks/data/library/techarticle/0211yip/0211yip3.html

They come under COBOl/400, Robert: publib.boulder.ibm.com/infocenter/iadthelp/v7r1/index.jsp?topic=/com.ibm.etools.iseries.langref.doc/c0925395587.htm
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Replace each space in cobol string wi... COBOL Programming 2
No new posts COBOL -Linkage Section-Case Sensitive COBOL Programming 1
No new posts Modifying Date Format Using DFSORT DFSORT/ICETOOL 9
No new posts COBOL ZOS Web Enablement Toolkit HTTP... COBOL Programming 0
No new posts Calling DFSORT from Cobol, using OUTF... DFSORT/ICETOOL 5
Search our Forums:

Back to Top