View previous topic :: View next topic
|
Author |
Message |
mflax
New User
Joined: 01 Sep 2006 Posts: 17 Location: Delhi
|
|
|
|
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 |
|
|
sarunkumaar
New User
Joined: 31 Aug 2006 Posts: 15 Location: Chennai, India
|
|
|
|
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 |
|
|
mflax
New User
Joined: 01 Sep 2006 Posts: 17 Location: Delhi
|
|
|
|
Thanks for reply. It is a COBOL-DB2 program.
What functions can be added ? |
|
Back to top |
|
|
sarunkumaar
New User
Joined: 31 Aug 2006 Posts: 15 Location: Chennai, India
|
|
|
|
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 |
|
|
sarunkumaar
New User
Joined: 31 Aug 2006 Posts: 15 Location: Chennai, India
|
|
|
|
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 |
|
|
mflax
New User
Joined: 01 Sep 2006 Posts: 17 Location: Delhi
|
|
|
|
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 |
|
|
mmwife
Super Moderator
Joined: 30 May 2003 Posts: 1592
|
|
|
|
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 |
|
|
priyesh.agrawal
Senior Member
Joined: 28 Mar 2005 Posts: 1448 Location: Chicago, IL
|
|
|
|
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 |
|
|
sumansyed
New User
Joined: 05 Apr 2005 Posts: 1
|
|
|
|
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 |
|
|
mmwife
Super Moderator
Joined: 30 May 2003 Posts: 1592
|
|
|
|
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 |
|
|
priyesh.agrawal
Senior Member
Joined: 28 Mar 2005 Posts: 1448 Location: Chicago, IL
|
|
|
|
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 |
|
|
|