Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Cobol Date functions

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
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    Post subject: Cobol Date functions
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7223

PostPosted: Thu Apr 07, 2011 11:55 am    Post subject:
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: 7904
Location: Bellevue, IA

PostPosted: Thu Apr 07, 2011 2:58 pm    Post subject:
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    Post subject:
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: 1712
Location: UK

PostPosted: Thu Apr 07, 2011 7:00 pm    Post subject:
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

Active Member


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

PostPosted: Thu Apr 07, 2011 7:09 pm    Post subject:
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    Post subject:
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    Post subject:
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    Post subject: Reply to: Cobol Date functions
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: 7904
Location: Bellevue, IA

PostPosted: Tue Jul 05, 2011 3:51 pm    Post subject:
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

Senior Member


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

PostPosted: Tue Jul 05, 2011 4:12 pm    Post subject: Reply to: Cobol Date functions
Reply with quote

santohsks1987,

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

They come under COBOl/400, Robert: http://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    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
This topic is locked: you cannot edit posts or make replies. RANDOM Function in COBOL swapnil781 COBOL Programming 2 Tue Nov 15, 2016 6:17 pm
No new posts TOT & DATE parameter in ICEMAN hemanthj642 DFSORT/ICETOOL 4 Mon Nov 14, 2016 5:19 am
No new posts Regarding COBOL Stored Procedure opti... selvamsrinivasan85 DB2 4 Fri Nov 04, 2016 8:57 pm
No new posts COBOL Version 6.1 Virendra Shambharkar COBOL Programming 5 Tue Nov 01, 2016 11:24 am
No new posts Cobol list of programs being called biswajit.dattagupta COBOL Programming 5 Tue Nov 01, 2016 2:10 am


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us