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

How to add days to date in COBOL-DB2 program


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

New User


Joined: 01 Sep 2006
Posts: 17
Location: Delhi

PostPosted: Fri Sep 01, 2006 10:24 am
Reply with quote

I have some req in cobol and I've to add some days to a julian date.

ex.
Date 9(7)- 2005360 (360th day of 2005)
Day S9(3) - +010
Result 9(7)- 2006005 means (5th day of 2006)

I can hardcode the logic to the program, but I was looking for if there is any function in cobol where I can give inputs as DATE and DAY and I can get output date.

Thanks all for helping me in advance.
Back to top
View user's profile Send private message
sarunkumaar

New User


Joined: 31 Aug 2006
Posts: 15
Location: Chennai, India

PostPosted: Fri Sep 01, 2006 10:36 am
Reply with quote

Is it a COBOL-DB2 program or a simple COBOL program ? Suppose if it's a COBOL-DB2 program then functions are there to add days to date ?
Back to top
View user's profile Send private message
mflax

New User


Joined: 01 Sep 2006
Posts: 17
Location: Delhi

PostPosted: Fri Sep 01, 2006 10:40 am
Reply with quote

Thanks for reply. It is a COBOL-DB2 program.

What functions can be added ?
Back to top
View user's profile Send private message
sarunkumaar

New User


Joined: 31 Aug 2006
Posts: 15
Location: Chennai, India

PostPosted: Fri Sep 01, 2006 11:19 am
Reply with quote

First convert the Julian date to normal date format i.e to YYYY-MM-DD. Then you can add/subract days using following query.


SELECT :WS-DATE + 10 DAY
FROM SYSIBM.SYSDUMMY1;

Where WS-DATE is the Host variable having value of converted date.

I quess you may have some routine to do the date conversion in your system.
Back to top
View user's profile Send private message
sarunkumaar

New User


Joined: 31 Aug 2006
Posts: 15
Location: Chennai, India

PostPosted: Fri Sep 01, 2006 11:53 am
Reply with quote

JULIAN_DAY function is there to convert from Gregorian to Julian format. I am not sure whether a function available to do vice-versa in DB2.
Back to top
View user's profile Send private message
mflax

New User


Joined: 01 Sep 2006
Posts: 17
Location: Delhi

PostPosted: Sat Sep 02, 2006 2:00 am
Reply with quote

ok, if I have converted date from Julian to normal format such as YYYY-MM-DD then what query I need to write to add some specific number of days.
Back to top
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Sat Sep 02, 2006 7:59 pm
Reply with quote

If you want to do it w/o DB2 use:

INTEGER-OF-DAY, add 10 to the integer then DAY-OF-INTEGER

I think your 1st instict was best. Hard code it. The IFs or DB2 add a lot of O'head. But don't forget the the leap year.

On the other hand, if you only do it once in the pgm it doesn't matter.
Back to top
View user's profile Send private message
priyesh.agrawal

Senior Member


Joined: 28 Mar 2005
Posts: 1448
Location: Chicago, IL

PostPosted: Wed Sep 06, 2006 7:17 am
Reply with quote

Hi mmwife,

No contradictions to you... just curious to know why do hard coding can be a better approach than Cobol Functions here... because are not we avoiding leap years calculations by using functions here...
Back to top
View user's profile Send private message
sumansyed

New User


Joined: 05 Apr 2005
Posts: 1

PostPosted: Wed Sep 06, 2006 8:59 am
Reply with quote

Hi mflax,

If you can get the date converted.
Query provided by our friend sarunkumaar will serve the purpose.

Please correct if i am wrong.
Back to top
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Thu Sep 07, 2006 3:46 am
Reply with quote

Hi Priyesh,

Of course it depends on the situation, but some these COBOL supplied functions come with substantial ohead. Many invoke programs and they are usually generalized to handel a wide variety of situations.

Sometimes looking at the generated assembler code will give you a feel for the kind of ohead involved, But here I think you'll find a call to another pgm is involved.
Back to top
View user's profile Send private message
priyesh.agrawal

Senior Member


Joined: 28 Mar 2005
Posts: 1448
Location: Chicago, IL

PostPosted: Thu Sep 07, 2006 8:37 am
Reply with quote

Thanks Much mmwife...
Quote:
Of course it depends on the situation, but some these COBOL supplied functions come with substantial ohead. Many invoke programs and they are usually generalized to handel a wide variety of situations.

Actually I was also involved in such stuff few days back when I used INTEGER-OF-DATE & DATE-OF-INTEGER for such DATE ARITHMETIC.
Thats why was more curious to know about it.

anyway, seems MFLAX would have got the answer till now... Isn't it ?
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 Replacing 'YYMMDD' with date, varying... SYNCSORT 3
No new posts Replace each space in cobol string wi... COBOL Programming 3
No new posts Using API Gateway from CICS program CICS 0
No new posts COBOL -Linkage Section-Case Sensitive COBOL Programming 1
No new posts Modifying Date Format Using DFSORT DFSORT/ICETOOL 9
Search our Forums:

Back to Top