Page 1 of 1

Timestamp conversion

Posted: Fri Aug 21, 2009 6:38 am
by arnie_nits
Hi,

I am unable to convert 28-09-2008 01:01:00 to 2008-09-28 01:01:00. How to do this with Iconv and Oconv.

Regards,
Arnie

Posted: Fri Aug 21, 2009 7:11 am
by ArndW
DataStage server has no timestamp, just Date and Time, so both parts need to be done separately. Assuming you have a string input value you need to:
Step 1, convert date to internal : ICONV(In.Date[1,10],'D4-DMY')
Step 2 convert internal to date : OCONV(Step1Result,'D4-YMD')

Everything in one line:

Code: Select all

OCONV(ICONV(In.Date[1,10],'D4-DMY'),'D4-YMD'):In.Date[11,9]

Posted: Fri Aug 21, 2009 11:32 pm
by laknar
Try this

Code: Select all

Oconv(ICONV(In.Date[1,10],"D-MY(2,2,4)"),"Y-MD(4,2,2)"):Right(In.Date,9)

Posted: Sat Aug 22, 2009 7:14 pm
by ray.wurlod
laknar wrote:Try this

Code: Select all

Oconv(ICONV(In.Date[1,10],"D-MY(2,2,4)"),"Y-MD(4,2,2)"):Right(In.Date,9)
Almost, but not quite (and therefore wrong). You left the day specifications out of Iconv and Oconv arguments.

Code: Select all

Oconv(Iconv(Left(In.Date,10), "DDMY"), "D-YMD[4,2,2]") : Right(In.Date, 9)