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

Conversion of MMDDYY Date to Julian DAte


IBM Mainframe Forums -> PL/I & Assembler
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
prasanth_urs

New User


Joined: 04 Dec 2006
Posts: 44
Location: Pune,India

PostPosted: Wed Jan 31, 2007 11:29 am
Reply with quote

Hi all,

Can anyone please tell me how to convert a Date in format MMDDYY to Julian Date....

For example DAte = 01312007
So the respective date should be like 31.(addding up the total number of days upto that point in an year).

Please reply me as soon as possible.

Many Thanks in advance icon_lol.gif
Back to top
View user's profile Send private message
Santoshdorge

New User


Joined: 27 Jun 2006
Posts: 48
Location: Pune

PostPosted: Wed Jan 31, 2007 1:05 pm
Reply with quote

Hi
One way is using the COBOL table/array. you can initialize of 12 elements to default number of days.For Feb you have to put logic for 28 or 29 days
depanding upon the year.Add the elements upto current month and then the day of the current month.
Another way to do this is by using DB2 functions.
Back to top
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3156
Location: Tucson AZ

PostPosted: Wed Jan 31, 2007 1:11 pm
Reply with quote

What language/tools do you have to work with?
Back to top
View user's profile Send private message
prasanth_urs

New User


Joined: 04 Dec 2006
Posts: 44
Location: Pune,India

PostPosted: Wed Jan 31, 2007 1:30 pm
Reply with quote

Hi ,

I am working with PL/I. I worked in COBOL before, but the requirement is in PL/I..
Back to top
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3156
Location: Tucson AZ

PostPosted: Wed Jan 31, 2007 1:51 pm
Reply with quote

There are LE routines that should be available to PL/I too.
If PL/I doesn't have anything available, you can just do what us "old timers" had to do in the "olden days".... Like Santoshdorge posted, a 12 entry table with the julian day for each month and a calculation for leap year - simple boiler plate coding.....
Back to top
View user's profile Send private message
kgumraj

Active User


Joined: 01 May 2006
Posts: 151
Location: Hyderabad

PostPosted: Thu Feb 01, 2007 2:06 pm
Reply with quote

Hi,

I can help you in db2. If you have DB2 in your program try this


Code:

EXEC SQL
         SELECT DAYS(DATE(:INDATE-IN-YYYY-MM-DD) + 1 DAY)
                     - DAYS('2007-01-01')
                     FROM SYSIBM.SYSDUMMY1
END-EXEC.


For the above, you need to code in PL1 for conversion of MMDDYYYY to YYYY-MM-DD format
Back to top
View user's profile Send private message
jayaprakashysr
Currently Banned

New User


Joined: 04 Jul 2007
Posts: 1
Location: HYD

PostPosted: Tue Nov 13, 2007 4:58 pm
Reply with quote

declare external entry
DCL K0B3S31 EXTERNAL ENTRY;
%INCLUDE CHGCOPY;
DATECHG_@STRUCT='';

CHGCOPY : copybook

DCL DATECHG_PTR POINTER;
DATECHG_PTR = ADDR (DATECHG_@STRUCT);

DCL 1 DATECHG_@STRUCT,
5 MMDDYY CHAR (6), /* INPUT/OUTPUT OF SUBRTN */
5 JULIAN PIC '99999', /* INPUT/OUTPUT OF SUBRTN */
5 RET_CODE CHAR (1); /* OUTPUT FROM SUBRTN */

DCL 1 DATECHG_REDEF BASED (DATECHG_PTR),
5 CALENDAR_PIC,
10 MONTH PIC '99',
10 DAY PIC '99',
10 YEAR PIC '99',
5 JULIAN_PIC,
10 YY PIC '99',
10 DDD PIC '999';

DCL 1 CHG_RET,
2 ALL_OK CHAR (1) INIT ('0'),
2 MMDDYY_NG CHAR (1) INIT ('1'),
2 JULIAN_NG CHAR (1) INIT ('2'),
2 REQ_NG CHAR (1) INIT ('3'); /* JULIAN = 0 AND */
/* MMDDYY IS BLANK */

/* CONVERT DATE TO JULIAN FORMAT */
DATECHG_@STRUCT = '';
DATECHG_@STRUCT.MMDDYY = SUBSTR(HOLD_PROCESS_DATE,5,2)
|| SUBSTR(HOLD_PROCESS_DATE,7,2)
|| SUBSTR(HOLD_PROCESS_DATE,3,2)
CALL K0B3S31(DATECHG_@STRUCT);
PARM_DATE_JUL = DATECHG_@STRUCT.JULIAN;


DCL PARM_DATE_JUL PIC'(05)9' INIT(0);

HOLD_PROCESS_DATE is your current date format

i hope this is clear for every one..........

Thanks,
Jayaprakash
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10872
Location: italy

PostPosted: Tue Nov 13, 2007 5:03 pm
Reply with quote

Quote:
CALL K0B3S31(DATECHG_@STRUCT);
PARM_DATE_JUL = DATECHG_@STRUCT.JULIAN;


DCL PARM_DATE_JUL PIC'(05)9' INIT(0);

HOLD_PROCESS_DATE is your current date format

i hope this is clear for every one..........


clear, but, ... COMPLETELY USELESS

k0b3s31 is an installation developed subroutine/function so it' s of no help to the O/P

as advised many times... avoid posting suggestions based on "in house" tools/facilities
Back to top
View user's profile Send private message
Srihari Gonugunta

Active User


Joined: 14 Sep 2007
Posts: 295
Location: Singapore

PostPosted: Tue Nov 13, 2007 8:06 pm
Reply with quote

If you're using the new Enterprise PL/I compiler, you can use the built in function REPATTERN:
greg8dig = REPATTERN(jul7dig , 'YYYYMMDD' , 'YYYYDDD');
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 -> PL/I & Assembler

 


Similar Topics
Topic Forum Replies
No new posts Replacing 'YYMMDD' with date, varying... SYNCSORT 3
No new posts Populate last day of the Month in MMD... SYNCSORT 2
No new posts Modifying Date Format Using DFSORT DFSORT/ICETOOL 9
No new posts 10 byte RBA conversion DB2 2
No new posts 10 byte RBA conversion -non applicati... JCL & VSAM 1
Search our Forums:

Back to Top