Date Conversation

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
prasad_chennai
Participant
Posts: 38
Joined: Wed Jul 18, 2007 12:23 am
Location: Chennai

Date Conversation

Post by prasad_chennai »

Hi All,
I need to Convert date format from 'dd-mmm-yyy ' to 'mm/dd/yyyy'.
and i am using th efollowing function to achieve the same.But just the date value (dd) is getting truncated to month start date.

StringToDate(DateToString(StringToDate(Trim(LNK_Read_Input.IND_DT), "dd-%mmm-%yy"), "%mm/%dd/%2000yy"),"%mm/%dd/%2000yy")

Code: Select all

Eg:
Varchar             Current O/p             Expected
20-DEC-15  -------    12/1/2015    --------12/20/2015
20-MAR-14  -------     3/1/2014      --------3/20/2014

Thanks,
prasad.
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

A Date type column has no format. You need to give a format when converting a string to a date and a format to display a date. Are your input and your output columns of type string?
prasad_chennai
Participant
Posts: 38
Joined: Wed Jul 18, 2007 12:23 am
Location: Chennai

Post by prasad_chennai »

Source is In Varchar while target is date(mm/dd/yyyy).
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Source is VarChar while target is Date. Date does NOT have a format.

Therefore

Code: Select all

StringToDate(Trim(LNK_Read_Input.IND_DT), "dd-%mmm-%yy")
should suffice.
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