Page 1 of 1

Convert date from YYDDD to MM-DD-YYYY format using sort.

PostPosted: Fri Apr 10, 2015 6:40 pm
by arpitpatel01
Hi,
Need ur help.

I have an input date which is in YYDDD format. I need to convert it to MM-DD-YYYY format using SORT.

Input:
14012
19012
16156

Output:
01-12-2014
01-12-1919
06-04-1916

Kindly help!

Thanks in advance!

Re: Convert date from YYDDD to MM-DD-YYYY format using sort.

PostPosted: Fri Apr 10, 2015 6:56 pm
by arpitpatel01
The required job ia being done using either of the below sort cards:

SORT FIELDS=COPY
INREC BUILD=(1:1,5,Y2T,TOGREG=(Y4T(-)))


OR

SORT FIELDS=COPY
INREC BUILD=(1:1,5,Y2T,DT=(4MD/))


But the issue is that for the input date as 19012, it is giving output as 2019-05-03. But i want 1919-05-03 in output.

Re: Convert date from YYDDD to MM-DD-YYYY format using sort.

PostPosted: Fri Apr 10, 2015 9:06 pm
by BillyBoyo
I've a feeling that because your date range is 102 years, you won't be able to do it like that anyway. Have a little search in the DFSORT documentation, for the word "window". I think you'll need additional coding. You must have some formula for knowing, already. Does it have to change each year?

Re: Convert date from YYDDD to MM-DD-YYYY format using sort.

PostPosted: Mon Apr 13, 2015 11:39 am
by arpitpatel01
@ BillyBoyo: Yes... it will change every year.
The functionality would be same as per GOADTE01 date converter utility with no offset range defined for date conversion.

Re: Convert date from YYDDD to MM-DD-YYYY format using sort.

PostPosted: Mon Apr 13, 2015 11:49 am
by BillyBoyo
Well, if you have a range of more than 100 years, strictly, more than 99 years, you need additional information to be able to know which century to attach to a date. If your range is 1916-2015, then when a 12 appears as the year, DFSORT is going to treat it as 2012. If there is other information on the record to identify it as not 2012, you have to use that information yourself. How did you know the date was wrong? Use that.

Re: Convert date from YYDDD to MM-DD-YYYY format using sort.

PostPosted: Mon Apr 13, 2015 2:25 pm
by arpitpatel01
Well, that was checked using GOADTE01 utility in Workbench.

Re: Convert date from YYDDD to MM-DD-YYYY format using sort.

PostPosted: Mon Apr 13, 2015 3:00 pm
by enrico-sorichetti
play around with
OPTION Y2PAST=

using different window year to find out a behaviour acceptable to Your environment

Re: Convert date from YYDDD to MM-DD-YYYY format using sort.

PostPosted: Mon Apr 13, 2015 3:53 pm
by NicC
I googled GOADTE01 and got 0 hits so I guess that is some internal utility unknown to anyone except those that work in your company so mentioning it here, by name, is pointless!

Re: Convert date from YYDDD to MM-DD-YYYY format using sort.

PostPosted: Fri Apr 24, 2015 8:13 pm
by arpitpatel01
Yes NicC... you are correct it is being used in our company. Thanks

Anyways, i got the approach for the abvoe requirement...
Whenever the date conversion is happening... the lowest cut-off date is calculated as (CURRENT-YEAR - 99) and then it is compared with the input date and then the date conversion takes place.

Will post the actual solution once we are done with its build...

Thanks all for your help! :)