Page 1 of 1

Varchar to Timestamp Conversion

Posted: Thu Nov 04, 2010 6:51 am
by Harini
Hello All,

Below is a varchar and i need to convert it to timestamp length 23, scale 3..

2009-01-15T00:08:13.109.

I used the below code and it doesnt work...

StringToTimestamp(DSLink316.DATE,"%yyyy-%mm-%dd %hh:%nn:%ss")

Any idea on the right code??

Thanks

Posted: Thu Nov 04, 2010 6:55 am
by ArndW
StringToTimestamp(DSLink316.DATE[1,10]:' ':DSLink316.DATE[12,12],"%yyyy-%mm-%dd %hh:%nn:%ss.3")

Posted: Thu Nov 04, 2010 7:13 am
by chulett
In other words, by skipping the 'T' separator. :wink:

Posted: Thu Nov 04, 2010 8:22 am
by Harini
ArndW wrote:StringToTimestamp(DSLink316.DATE[1,10]:' ':DSLink316.DATE[12,12],"%yyyy-%mm-%dd %hh:%nn:%ss.3") ...
Thanks, that worked ! :)

Posted: Thu Nov 04, 2010 8:28 am
by ArndW
Craig - you gave away the secret 8)

Posted: Thu Nov 04, 2010 10:13 am
by chulett
D'oh! :cry:

Posted: Fri Nov 05, 2010 12:00 am
by ray.wurlod
Just curious (and unable to check at the moment) - can you include the literal T in the format string? That would yield a simpler and self-documented solution.