How to transform a string into timestamp in DataStage?

wtm picture wtm · Jul 16, 2012 · Viewed 12.9k times · Source

I read data from a csv file,and I get a string like "2010-7-3", I can't transform this data into timestamp,because it not like "2010-07-03"

What should I do?Is there a stage could handle this?

Answer

lins314159 picture lins314159 · Jul 20, 2012

In the transformer, set up three stage variables - year, month and day. Their respective values should be as follows

Field(InputLink.string_date, "-", 1)
Right("0" : Field(InputLink.string_date, "-", 2), 2)
Right("0" : Field(InputLink.string_date, "-", 3), 2)

Then use this in the output column:

StringToTimestamp(year : month : day : "000000", "%yyyy%mm%dd%hh%nn%ss")