Page 1 of 1

converting timestamp

Posted: Thu Apr 03, 2008 7:52 am
by venkycool
Hi All,

I am trying to convert the date value as in source the field is in NVarchar and in target (SQL) the field is in Timestamp. I need to convert the value like 1/10/08 9:33 (from source) to timestamp (in target). Tried string to timestamp and left function and all..I am missing some simple logic here....Thanks in advance!

Posted: Thu Apr 03, 2008 5:20 pm
by ray.wurlod
You need to re-assemble the various components of the source string into a timestamp format, and then apply a StringToTimestamp() function. One issue that you'll need to address is a consistent, two-digit, format for month and day; another is the business rule for the century in which a two-digit year occurs; a third is adding seconds to the timestamp format.

It's do-able, it's not difficult, but it IS tedious (but you only have to do it the once).

Posted: Thu Apr 03, 2008 11:46 pm
by John Smith
what is the source of your data ? is that an Excel spreadsheet or a database? perhaps the formatting could be pushed back to the source to get it a a string which can be easily converted using StringToTimestamp.
just a thot.

Posted: Fri Apr 04, 2008 8:42 am
by venkycool
Hi,

Yes, I am reading the .csv file in sequential file. Tried different ways, still its not working.

Posted: Fri Apr 04, 2008 8:51 am
by DSguru2B
:idea: Make sure that your timestamp has a two digit month and a two digit day else StringToTimestamp() will complain or simple not work.

Posted: Fri Apr 04, 2008 1:06 pm
by venkycool
BINGO!!!!!!!!!!

Thanks DSguru......I have changed it as two digit and it worked like missile....Appreciate it!!