converting 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
swathi Singamareddygari
Participant
Posts: 48
Joined: Fri Feb 29, 2008 1:09 am
Location: Bangalore

converting string to timestamp

Post by swathi Singamareddygari »

Hi All,

In my project we use DB2 as source,I am loading data into a dataset which is having field with decimal type.I am converting this to timestamp
using 2 step conversion first convertnig decimal to string and again converting that string to timestamp.when i am converting string to timestamp its returing *** in the output.

I any one have answer plz let me know
Thanks&Regards
S.Swathi
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

Hello and welcome to DSXChange.

First try to isolate the error. Convert your decimal to a string and put the output into a file or a peek stage. Does it convert correctly as you expect? If yes, then please post a couple of sample values and also your StringToTimeStamp() conversion statement.
swathi Singamareddygari
Participant
Posts: 48
Joined: Fri Feb 29, 2008 1:09 am
Location: Bangalore

Post by swathi Singamareddygari »

Hello
I did the isolation of the conversion also.
when converting from decimal to string the sample output is

000000085363200.00000
000000000086400.00000
000000000172800.00000
but when i am converting from string to timestamp its giving '*********'
Thanks&Regards
S.Swathi
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

Please post your StringToTimeStamp derivation.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Please post not only the derivation but also one or two samples of the strings you are attempting to convert.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
swathi Singamareddygari
Participant
Posts: 48
Joined: Fri Feb 29, 2008 1:09 am
Location: Bangalore

Post by swathi Singamareddygari »

Hello
I am posting the derivations ,
I want to convert the out_data.Duration from decimal to timestamp.
I am doing first conversion in stage variable

svr (stage variable)----> DecimalToString(out_data.Duration)

second conversion(string to timestamp) derivation is

StringToTimestamp(svr,'%yyyy-%mm-%dd %hh:%nn:%ss')
Thanks&Regards
S.Swathi
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

swathi Singamareddygari wrote:StringToTimestamp(svr,'%yyyy-%mm-%dd %hh:%nn:%ss')
What you are doing cannot work. Your string picture is in absolutely no way compatible with the decimal numbers you listed. You are telling DataStage to convert the number "85363200" into a date formatted
as listed above?
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

If your number is of the form 20080303 and you have converted it to a string then you can use StringToDate() but you must provide the correct format string ("%yyyy%mm%dd", with no delimiters). Because you have a string, you can concatenate the time portion and use StringToTimestamp(). Again you need an appropriate format string that describes the format of the string you are supplying.
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