Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
What is the length and format of your Julian date (CH, PD, ?) and what does it look like (yyyyddd? yyddd?). What is the length and format of the gregorian date you want and what does it look like?
File contains date in Julain format in PD in the format yyyyddd. Like to convert into the format yyyymmdd, or any other format that the situation demands.
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
DFSORT does not really have date conversion functions, but for the case you're talking about, there is a trick we can use to convert from P'yyyyddd' to Z'yyyymmdd' or P'yyyymmdd'.
Are you only dealing with 20yy dates or are you dealing with 19yy and 20yy dates? And do you want the output date to be ZD or PD?
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
Here's a DFSORT job that will handle both 19 and 20 dates and convert to both Z'yyyymmdd' and P'yyyymmdd'. I assumed the input P'yyyyddd' date starts in position 1, but you can change that as appropriate.
Code:
//S1 EXEC PGM=ICEMAN
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=... input file
//SORTOUT DD DSN=... output file
//SYSIN DD *
OPTION COPY
* Convert X'19yyddds' to X'00yyddds'.
* Convert X'20yyddds' to X'01yyddds'.
INREC FIELDS=(1:1,1,CHANGE=(1,X'19',X'00',X'20',X'01'),
NOMATCH=(X'02'),2:2,3)
* Use SMF date format (DT1) to convert X'0cyyddds' to Z'yyyymmdd'
* and P'yyyymmdd'.
OUTREC FIELDS=(1,4,DT1,X,1,4,DT1,TO=PD,LENGTH=5)
/*
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
DT1 actually converts a P'0cyyddd' date to a Z'yyyymmdd' date. You could then move the Z'yyyymmdd' bytes around to get Z'mmddyyyy', and if necessary, convert that to PD. Here's an example:
Code:
OPTION COPY
INREC IFTHEN=(WHEN=INIT,
* Convert X'19yyddds' to X'00yyddds'.
* Convert X'20yyddds' to X'01yyddds'
BUILD=(1:38,1,CHANGE=(1,X'19',X'00',X'20',X'01'),
NOMATCH=(X'02'),2:39,3)),
* Use SMF date format (DT1) to convert X'0cyyddds' to Z'yyyymmdd'
IFTHEN=(WHEN=INIT,BUILD=(1,4,DT1)),
* Convert Z'yyyymmdd' to Z'mmddyyyy' - stop here if you don't
* want P'0mmddyyyy'
IFTHEN=(WHEN=INIT,BUILD=(5,4,1,4)),
* Copy Z'mmddyyy' and convert Z'yyyymmdd' to P'0mmddyyyy'
IFTHEN=(WHEN=INIT,BUILD=(1,8,X,1,8,ZD,TO=PD,LENGTH=5))
I have a requirement like this. A Julian date of 5 digits (YYDDD) needs to be converted to Greg format of (MM/DD/YYYY). Input field is in CH format and want the output also in same. The date starts at position 6 in a FB file. Please let me know how I can achieve this using the ICEMAN?
NOMATCH tells DFSORT what to do if none of the CHANGE conditions are matched. For the statement above:
- if position 1 contains X'19', it is changed to X'00'
- if position 1 contains X'20', it is changed to X'01'
- if position 1 does not contain X'19' or X'20', it is changed to X'02'
For some more information on DFSORT's CHANGE and NOMATCH functions, see:
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
The job works fine with DFSORT. I'm a DFSORT developer. DFSORT and Syncsort are competitive products. I'm happy to answer questions on DFSORT and DFSORT's ICETOOL, but I don't answer questions on Syncsort.
//* 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.