Page 1 of 1

Date Conversation

Posted: Tue Feb 26, 2008 1:59 am
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.

Posted: Tue Feb 26, 2008 2:07 am
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?

Posted: Tue Feb 26, 2008 2:59 am
by prasad_chennai
Source is In Varchar while target is date(mm/dd/yyyy).

Posted: Tue Feb 26, 2008 3:52 am
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.