string conversion 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
ramesh_g
Participant
Posts: 1
Joined: Tue Apr 18, 2006 10:53 am

string conversion to timestamp

Post by ramesh_g »

I have source defined as time stamp.But I am getting only date now...later I may get complete time stamp.I am using stringtotimestamp function to convert it using format ,["%yyyy-%mm-%dd %hh:%nn:%ss".Since I am not getting time along with how can I am appending :00:00:00.How can I handle when it comes as complete time stamp in future.( I can not keep append/hard code with 00:00:00).
BugFree
Participant
Posts: 82
Joined: Wed Dec 13, 2006 6:02 am

Post by BugFree »

You can check if the length of the input string.

Code: Select all

If len(trim(In.Field)) = 19 Then StringToTimespamp(In.Field,"%yyyy-%mm-%dd %hh:%nn:%ss") Else StringToTimespamp(In.Field : " 00:00:00","%yyyy-%mm-%dd %hh:%nn:%ss")
The above code will work only if the input is a timestamp or just the date.
Ping me if I am wrong...
Post Reply