Sunday, February 19, 2012

Converting the string value to data format

Hello Everyone,

Please guide me in converting the value to date format.

from source i'm getting the value (which is acchally a data value) '20070730'.

I need this value to be in date format '2007/07/30'

Please help me in getting it done.

thank you

Hi

Code Snippet

select cast('20070730' as datetime)

Note : beware of collation used in your SQL instance or your database.

--

Jean-Pierre

|||

THANK YOU FOR YOUR REPLY.

bUT MY SOURCE IS FALAT FILE

|||

HI, you van use a derived column with the following expression:

(DT_DBTIMESTAMP)(SUBSTRING(Column,1,4) + "-" + SUBSTRING(Column,5,2) + "-" + SUBSTRING(Column,7,2))

HTH,

Ccote

No comments:

Post a Comment