View previous topic :: View next topic
|
Author |
Message |
steves
New User
Joined: 26 Feb 2007 Posts: 30 Location: chicago
|
|
|
|
I've been searching this web site and the internet in general for about 2 days looking for code samples on converting yyyyddd date format to mmddyy. Everything I've seen online says to use standard cobol functions DATE-OF-INTEGER, etc or that the shop I work at should have some code written in house. Every place I've worked in the past has some some code written in house. This place may actually have some code written in house, but they've laid off all of their mainframe staff and I'm not able to find anything. ( No they don't have version control, no, no one knows the names of the production source libraries)
So where might I find actual code samples, hopefully written in COBOL ? I've tried IBM manuals and didn't find it
thanks |
|
Back to top |
|
|
Bill O'Boyle
CICS Moderator
Joined: 14 Jan 2008 Posts: 2501 Location: Atlanta, Georgia, USA
|
|
|
|
Language Environment Callable Service routines can perform this conversion for you. Check with your System's personnel for availability.
Use ===> CEEDAYS (step 01)
Use ===> CEEDATE (step 02)
COBOL FUNCTIONS were introduced with COBOL/370 in the early 1990's.
LE can be installed in OS/VS COBOL and VS/COBOL II. It became an integral part of COBOL/370.
Bill |
|
Back to top |
|
|
steves
New User
Joined: 26 Feb 2007 Posts: 30 Location: chicago
|
|
|
|
thanks but
there are no mainframe developers or staff here
this is an old system the client is a government agency they replaced the system years ago and hired me to extract all the historical data and move it to oracle. there is no one here to ask
I'm looking for a sample source code not a callable function. if I can't find one I'll have to write one |
|
Back to top |
|
|
Bill O'Boyle
CICS Moderator
Joined: 14 Jan 2008 Posts: 2501 Location: Atlanta, Georgia, USA
|
|
|
|
Do you know REXX? You could write a REXX callable routine to perform this conversion or you can write a COBOL version yourself.
You've got quite a mess on your hands.
What version of COBOL are you working with?
Try Googling "Julian to Gregorian in COBOL". You might get lucky and find some freeware.
Bill |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
something that I stole from Kolusu:
Code: |
01 WS-GREGORIAN-DATE PIC 9(08).
01 WS-JULIAN-DATE PIC 9(07).
COMPUTE WS-JULIAN-DATE = FUNCTION DAY-OF-INTEGER
(FUNCTION INTEGER-OF-DATE
(WS-GREGORIAN-DATE))
COMPUTE WS-GREGORIAN-DATE = FUNCTION DATE-OF-INTEGER
(FUNCTION INTEGER-OF-DAY
(WS-JULIAN-DATE))
|
|
|
Back to top |
|
|
steves
New User
Joined: 26 Feb 2007 Posts: 30 Location: chicago
|
|
|
|
thanks but per my original post I don't have access to cobol functions |
|
Back to top |
|
|
steves
New User
Joined: 26 Feb 2007 Posts: 30 Location: chicago
|
|
|
|
i've been googling Julian to Greg etc for 2 days. I think I'm just going to write my own program, the logic doesn't seem hard, I know how days are in a month thanks for you help |
|
Back to top |
|
|
Bill O'Boyle
CICS Moderator
Joined: 14 Jan 2008 Posts: 2501 Location: Atlanta, Georgia, USA
|
|
|
|
Dick,
He doesn't have access to COBOL FUNCTIONS, so that would mean that he's on OS/VS COBOL or VS/COBOL II.
Bill |
|
Back to top |
|
|
Bill O'Boyle
CICS Moderator
Joined: 14 Jan 2008 Posts: 2501 Location: Atlanta, Georgia, USA
|
|
|
|
steves wrote: |
i've been googling Julian to Greg etc for 2 days. I think I'm just going to write my own program, the logic doesn't seem hard, I know how days are in a month thanks for you help |
Don't forget leap year in your calculation
Bill |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
Sorry about the functions.
as bill said, don't forget about leap year,
and you can skip checking for leap year if the year ends in 1,3,5,7,9
if it is 0,4, or 8 it is a leap year,
so you only have to check for 2 or 6.
saves that divide in your routine. |
|
Back to top |
|
|
steves
New User
Joined: 26 Feb 2007 Posts: 30 Location: chicago
|
|
|
|
thanks |
|
Back to top |
|
|
PeterHolland
Global Moderator
Joined: 27 Oct 2009 Posts: 2481 Location: Netherlands, Amstelveen
|
|
|
|
Always thought that a leap year check was something like this :
Code: |
bool __fastcall DateTimeTricks::IsLeapYear(int AYear)
{
return((AYear % 4) == 0) && (((AYear % 100) != 0) || ((AYear % 400) == 0));
}; |
|
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
Peter,
you are correct.
I have no excuse for such a stupid comment.
(I do, but it is even stupider - I used the logic in a routine that was only going to be used from 2000 to 2008.)
dbzTHEdinosauer erronously wrote: |
as bill said, don't forget about leap year,
and you can skip checking for leap year if the year ends in 1,3,5,7,9
if it is 0,4, or 8 it is a leap year,
so you only have to check for 2 or 6.
saves that divide in your routine.
|
SHOULD BE:
and you can skip checking for leap year if the year ends in 1,3,5,7,9
so you only have to check for 0, 2 , 4, 6, or 8.
List of Leap Years |
|
Back to top |
|
|
|