converting 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
venkycool
Participant
Posts: 59
Joined: Fri Feb 16, 2007 12:24 am
Location: USA

converting timestamp

Post 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!
Suriv
No one is perfect... that's why pencils have erasers
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post 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).
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
John Smith
Charter Member
Charter Member
Posts: 193
Joined: Tue Sep 05, 2006 8:01 pm
Location: Australia

Post 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.
venkycool
Participant
Posts: 59
Joined: Fri Feb 16, 2007 12:24 am
Location: USA

Post by venkycool »

Hi,

Yes, I am reading the .csv file in sequential file. Tried different ways, still its not working.
Suriv
No one is perfect... that's why pencils have erasers
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post 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.
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
venkycool
Participant
Posts: 59
Joined: Fri Feb 16, 2007 12:24 am
Location: USA

Post by venkycool »

BINGO!!!!!!!!!!

Thanks DSguru......I have changed it as two digit and it worked like missile....Appreciate it!!
Suriv
No one is perfect... that's why pencils have erasers
Post Reply