Mainframe Date Convert

Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.

Moderators: chulett, rschirm, roy

Post Reply
kanasai167
Participant
Posts: 63
Joined: Mon Sep 12, 2011 2:11 am

Mainframe Date Convert

Post by kanasai167 »

1959047
1963112
1951356
1967027
1958213

this is the value of the date, i think the first 4 digit is the year ? and the remaining 3 is day of the year ? If so , how should i make it into yyyy-mm-dd format?
is there any ways to do it ?

thanks.
suse_dk
Participant
Posts: 93
Joined: Thu Aug 11, 2011 6:18 am
Location: Denmark

Post by suse_dk »

I presume it is defined as a string in the source?

So, split the string 'YYYYint' into YYYY (where you change it to a date YYYY-01-01) and the int value
Convert the date into a julian date
Add the two int values together (I think you need to subtract 1)
Convert the new julian date to the date format of your desire.
_________________
- Susanne
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

You should be able to use "%yyyy%ddd" as the date format string.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
suse_dk
Participant
Posts: 93
Joined: Thu Aug 11, 2011 6:18 am
Location: Denmark

Post by suse_dk »

ray.wurlod wrote:You should be able to use "%yyyy%ddd" as the date format string. ...
Needless to say that this would be a much better solution :)
_________________
- Susanne
rajadommeti
Premium Member
Premium Member
Posts: 43
Joined: Wed Feb 27, 2008 1:08 am

Re: Mainframe Date Convert

Post by rajadommeti »

select to_char(CAST(TO_DATE (yourdate, 'yyyyddd') as timestamp),'yyyy-mm-dd') from yourtable;
RAJ
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Re: Mainframe Date Convert

Post by ray.wurlod »

rajadommeti wrote:select to_char(CAST(TO_DATE (yourdate, 'yyyyddd') as timestamp),'yyyy-mm-dd') from yourtable;
Why do you think the source is a database (and what kind of database do you believe it to be)? Source data are coming from a mainframe, and its structure is defined in a COBOL file definition.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Post Reply