string 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
saikiran
Premium Member
Premium Member
Posts: 18
Joined: Wed Aug 20, 2008 11:28 pm

string to timestamp

Post by saikiran »

Hello DSgurus,

I need to convert the source column which is in format hh:nn:ss to timestamp.Souce is sequential file and the target is oracle table.Can anyone crack this :)

Thank you
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Can't you just wrap this in a TO_DATE function in the INSERT statement?
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

hh:nn:ss? nn? Am I missing something or did you mean hh:mm:ss? And what are you planning on doing for a date... or did you mean an Oracle INTERVAL field rather than a TIMESTAMP? :?
-craig

"You can never have too many knives" -- Logan Nine Fingers
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

It's not necessary to have multiple threads open for the same question. Please delete your other post.

The easy choice is to add a date to the front of your time, then convert the whole to a timestamp.

Code: Select all

StringToTimestamp(DateToString(CurrentDate, "%yyyy-%mm-%dd") : " " : InLink.MyTime)
In this example I am assuming that your default timestamp format string is the usual default (YYYY-MM-DD HH24:MI:SS).
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
saikiran
Premium Member
Premium Member
Posts: 18
Joined: Wed Aug 20, 2008 11:28 pm

Post by saikiran »

ray.wurlod wrote:It's not necessary to have multiple threads open for the same question. Please delete your other post.

The easy choice is to add a date to the front of your time, then convert the whole to a timestamp.

Code: Select all

StringToTimestamp(DateToString(CurrentDate, "%yyyy-%mm-%dd") : " " : InLink.MyTime)
In this example I am assuming that your default timestamp format string is the usual default (YYYY-MM-DD HH24:MI:SS).


Hello,
The format i/p format is hh:mi:ss and the datatype is varchar .....My output should be the same but the datatype should be timestamp
Thank you
Sai
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

You can't have a timestamp without a date component. What date do you want to use for the date component?
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Post Reply