String to TimeStamp Conversion

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
nima511
Participant
Posts: 22
Joined: Thu Oct 08, 2009 8:01 am

String to TimeStamp Conversion

Post by nima511 »

I have an input field as below
date_opened
2010-01-05 13:14:16.130

I am reading it as a Varchar and I have also tried Varchar(26).
In my transformer I use :
StringToTimestamp(DSLink35.date_opened,"%yyyy-%mm-%dd %hh:%nn:%ss")

My output is a sequential file and the column is defined as a timestamp.
My problem is :
1) If the input has a value it seems fine but when there is no data on the input my output looks like "*******************". How can I see just a blank instead of the *'s.
2) And eventually I would want to load this into a SQL Server and I am getting an error with the str to ts conversion.
anbu
Premium Member
Premium Member
Posts: 596
Joined: Sat Feb 18, 2006 2:25 am
Location: india

Post by anbu »

Code: Select all

If Trim(DSLink35.date_opened) = '' Then '' Else StringToTimestamp(DSLink35.date_opened,"%yyyy-%mm-%dd %hh:%nn:%ss") 
You are the creator of your destiny - Swami Vivekananda
nima511
Participant
Posts: 22
Joined: Thu Oct 08, 2009 8:01 am

Post by nima511 »

Anbu, Do you mean
If Len(Trim(DSLink35.date_opened) = 0) Then ''" Else StringToTimestamp(DSLink35.DT_OPENED,"%yyyy-%mm-%dd %hh:%nn:%ss")
anbu
Premium Member
Premium Member
Posts: 596
Joined: Sat Feb 18, 2006 2:25 am
Location: india

Post by anbu »

Yes
You are the creator of your destiny - Swami Vivekananda
nima511
Participant
Posts: 22
Joined: Thu Oct 08, 2009 8:01 am

Post by nima511 »

I am still getting the same output.
anbu
Premium Member
Premium Member
Posts: 596
Joined: Sat Feb 18, 2006 2:25 am
Location: india

Post by anbu »

If you are writing to a file, then you dont need to use the function StringToTimestamp. Timestamp is considered as string in text file

Try removing the function and run the job
You are the creator of your destiny - Swami Vivekananda
vinothkumar
Participant
Posts: 342
Joined: Tue Nov 04, 2008 10:38 am
Location: Chennai, India

Post by vinothkumar »

Please post the warning message that you are getting.
nima511
Participant
Posts: 22
Joined: Thu Oct 08, 2009 8:01 am

Post by nima511 »

Transformer_45,0: Conversion error calling conversion routine date_from_string data may have been lost
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Have you got a StringToDate() function in a different derivation?

The error message talks about date_from_string, not timestamp_from_string.

Also, you need a timestamp format string that allows for fractional seconds if you wish to keep these.
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