//* Convert Julian date to Gregorian date
//*
//* Example:1
//S1 EXEC PGM=ICEMAN
//SYSOUT DD SYSOUT=*
//SORTIN DD Input file with "Hex format date of 1945001"
//*1401
//*950F
//SYSIN DD *
OPTION COPY
INREC IFTHEN=(WHEN=INIT,
BUILD=(1:1,1,CHANGE=(1,X'19',X'00',X'20',X'01'),
NOMATCH=(X'02'),2:2,3)),
IFTHEN=(WHEN=INIT,BUILD=(1,4,DT1)), yyyyddd to yyyymmdd
* IFTHEN=(WHEN=INIT,BUILD=(5,4,1,4)), yyyymmdd to mmddyyyy
* IFTHEN=(WHEN=INIT,BUILD=(5,2,C'-',7,2,C'-',1,4)) yyyymmdd to mm-dd-yyyy
* IFTHEN=(WHEN=INIT,BUILD=(1,4,X,1,4,ZD,TO=PD,LENGTH=5)) Zoneddec to Packeddec date
/*
//*
//* Example:2
//S1 EXEC PGM=ICEMAN
//SYSOUT DD SYSOUT=*
//SORTIN DD *
06012
/*
//SORTOUT DD SYSOUT=*
//SYSIN DD *
OPTION COPY
INREC IFTHEN=(WHEN=(1,2,ZD,GT,+49),
BUILD=(X'00',1,5,ZD,TO=PD,LENGTH=3)),
IFTHEN=(WHEN=NONE,
BUILD=(X'01',1,5,ZD,TO=PD,LENGTH=3))
OUTREC IFTHEN=(WHEN=INIT,
BUILD=(1,4,DT1)), X'00/01yydddC' to Z'19/20yymmdd'
* IFTHEN=(WHEN=INIT,
* BUILD=(5,2,C'-',7,2,C'-',1,4)) Z'19/20yymmdd' to C'mm-dd-ccyy'
/*
Quote:
I have gone through all the available threads on Date conversion from Julian date to Gregorian date and made these above 2 examples.
By the above examples I couldnt under stand how to perform the same logics for "n" number of dates at a time.
My concern is if I have 2 or more dates which need to convert from EX1: yyyyddd to mm-dd-yyyy EX2: yyddd to dd-mm-yyyy.... how can I achieve this, Kindly find the below example and help me how can I exactly use it here.
Code:
INPUT
Cust# Emp# DOB DEP DOJ
001 12345 á ECE 07001
FFF FFFFF 1401 CCC FFFFF
001 12345 950F 535 07001
123 45678 9012 345 6789
OUTPUT
Cust# Emp# DOB DEP DOJ
001 12345 01-01-1945 ECE 01-01-2007
123 45678 9012345678 901 2345678901
This is my first post, kindly regret if I any inconvenience provided.
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
I can't figure out what your input records represent or how they relate to your output records. You seem to have 4 input records and 2 output records and only the first output record has dates.
For example 1, are you just trying to convert several yyyyddd dates in the same record to mm-dd-yyyy dates? If so, what is the starting position, length and format of each yyyyddd date in the input file and what is the corresponding starting position of each mm-dd-yyyy date in the output file? What is the RECFM and LRECL of the input file?
For example 2, are you just trying to convert several yyddd dates in the same record to dd-mm-yyyy dates? If so, what is the starting position, length and format of each yyddd date in the input file and what is the corresponding starting position of each dd-mm-yyyy date in the output file? Also, are the yyddd dates all 20yyddd dates or can there also be 19yyddd dates as well? What is the RECFM and LRECL of the input file?
You seem to have 4 input records and 2 output records
It is evident that the poster was just trying to helpful by showing both the character and the hexadecimal representation of his data,
at least as far the first record is concerned
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
If that's the case, then I guess the first date field in the first record is a 4-byte PD field starting at position 13 (P'1945001' = X'1945001F') and the second date field in the first record is a 5-byte ZD field starting at position 22 (Z'07001').
But the second record still doesn't make sense and needs to be explained.
Sorry for not posting details properly in my previous post, now I have listed them.
Code:
INPUT (contains only one record)
Cust# Emp# DOB DEP DOJ <--- Header
001 12345 á ECE 07001 <--- Data
FFF FFFFF 1401 CCC FFFFF <--- Hexon line one
001 12345 950F 535 07001 <--- Hexon line two
123 45678 9012 345 67890 <--- Columns
OUTPUT (need only one record)
Cust# Emp# DOB DEP DOJ <--- Header
001 12345 01-01-1945 ECE 01-01-2007 <--- Data
123 45678 9012345678 901 2345678901 <--- Columns
Input file is of 80bytes FB, Date1(DOB) is an 4-byte PD starting at position 9 (X'1945001F') and Date2(DOJ) is an 5-byte ZD starting at position 16 (Z'07001').
I am unable to understand how to convert "n" number of dates at a time using the above technique(Ex:1 and EX:2 in previous post) given by Mr.Frank.
----------------------------
Suresh,
Hyderabad, India.
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
Here's a DFSORT job that will do what you asked for. I assumed that you wanted both output dates in the form mm-dd-yyyy. If you want dd-mm-yyyy that would require a simple change to the last IFTHEN clause.
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
With z/OS DFSORT V1R5 PTF UK51706 or z/OS DFSORT V1R10 PTF UK51707 (Nov, 2009), DFSORT now has built-in date conversion functions for these types of situations . For complete details on date conversion functions and the other new functions available with the Nov, 2009 DFSORT PTF, see: