View previous topic :: View next topic
|
Author |
Message |
prasanth_urs
New User
Joined: 04 Dec 2006 Posts: 44 Location: Pune,India
|
|
|
|
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 |
|
Back to top |
|
|
Santoshdorge
New User
Joined: 27 Jun 2006 Posts: 48 Location: Pune
|
|
|
|
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 |
|
|
William Thompson
Global Moderator
Joined: 18 Nov 2006 Posts: 3156 Location: Tucson AZ
|
|
|
|
What language/tools do you have to work with? |
|
Back to top |
|
|
prasanth_urs
New User
Joined: 04 Dec 2006 Posts: 44 Location: Pune,India
|
|
|
|
Hi ,
I am working with PL/I. I worked in COBOL before, but the requirement is in PL/I.. |
|
Back to top |
|
|
William Thompson
Global Moderator
Joined: 18 Nov 2006 Posts: 3156 Location: Tucson AZ
|
|
|
|
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 |
|
|
kgumraj
Active User
Joined: 01 May 2006 Posts: 151 Location: Hyderabad
|
|
|
|
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 |
|
|
jayaprakashysr Currently Banned New User
Joined: 04 Jul 2007 Posts: 1 Location: HYD
|
|
|
|
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 |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10873 Location: italy
|
|
|
|
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 |
|
|
Srihari Gonugunta
Active User
Joined: 14 Sep 2007 Posts: 295 Location: Singapore
|
|
|
|
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 |
|
|
|