How to convert mmddyy date format to yyyy-mm-dd

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
swerajan
Participant
Posts: 42
Joined: Tue Aug 05, 2008 4:34 am

How to convert mmddyy date format to yyyy-mm-dd

Post by swerajan »

Hi
I am getting a date in the format of mmddyy. I need to convert it to yyyy-mm-dd format. How can i achieve this?
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

You need to convert it into another string in that format, or you need to convert it into a date? There's a difference.
-craig

"You can never have too many knives" -- Logan Nine Fingers
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Dates don't have formats - they are binary. So what is your source? If it is a text file, for example, you have a string but, if you have specified a data type of Date, then the import operator will convert this to binary format based on the format string specified in your record schema.

The only time you need to convert this to a different format is if you are going to export it as a string data type (for example Char or VarChar).

You also need a business rule concerning your century pivot - which century applies given that you have only a two digit year component.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
swerajan
Participant
Posts: 42
Joined: Tue Aug 05, 2008 4:34 am

Post by swerajan »

@ Chulett- I need to convert the string in the format of mmddyy to date of fomat yyyy-mm-dd

I am loading it into the table which has date in the above mentioned format. The source is mainframes here.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

You can re-arrange (concatenate) the relevant substrings. You also need logic to add the century number according to your own (century pivot) business rules.

A less efficient approach would be to convert the source string into a date then to convert that date back to a string, with a different format specified in each case.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Kayalbaskaran
Participant
Posts: 10
Joined: Tue Jun 24, 2008 4:27 am

Post by Kayalbaskaran »

The below conversion would help you in converting the string to required date format

StringToDate(Input Column,"%mm%dd%1950yy")
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

No it won't. It will convert the string to a binary date. That's only half way to the required solution. You're also making an assumption about the century pivot year.
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