Converting a datetime defines as varchar field to timestamp

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
nguyenmk
Participant
Posts: 5
Joined: Tue Mar 14, 2006 5:06 pm

Converting a datetime defines as varchar field to timestamp

Post by nguyenmk »

Hi,

I have a datetime field defined as a varchar(20) and I need to convert it to a timestamp. The data coming in is from Teradata and is as follows:

10-MAY-2006 12:00:00

need to convert as

2006-05-10 12:00:00

I tried using StringToTimeStamp, but no luck. Any ideas how I can accomplish this?

Thanks,

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

Post by ArndW »

Michael - could you explain "no luck"? This is the correct function to perform the conversion.
nguyenmk
Participant
Posts: 5
Joined: Tue Mar 14, 2006 5:06 pm

Post by nguyenmk »

I got 19 asterisk characters "*******************"

I think the problem is the date format which has dd-mon-yyyy and I don't know how to convert that to yyyy-mm-dd, the StringtoTimeStamp expects a format of yyyy-mm-dd for the date.


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

Post by ArndW »

Michael,

the StringtoTimeStamp does not expect that format, it defaults to that format. You need to specify that you need a different format, using StringToTimeStamp(In.Col,"%dd-%mmm-%yyyy %hh:%nn:%ss")
Post Reply