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
praburaj
Premium Member
Premium Member
Posts: 133
Joined: Thu Jun 30, 2005 1:26 am
Location: philippines

TimeStamp

Post by praburaj »

Hi All,

My source column QT_Travel data type is TimeStamp and data is like I mentioned below.

Nov 11 1996 12:00AM

I have to split this data into two columns with date and time as a separate column into target table.

Expected Output:

Date Column-1996-11-09
Time Column-12:00:00

I have Used TimeStamp to Time format(Columnname,"%hh:nn:%ss") for time column. But job got aborted due to some records not in the proper timestamp format. I need to reject the invalid timestamp records then I have to split the data and load the data to the target table

Any help would be appreciated.
prabakaran.v
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

So this "timestamp" source column (QT_Travel) is it actually a string? Not sure how else one would not get "proper timestamp value". If so, can you show us some of these bad timestamps?
-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 »

TimestampToTime() function requires no format string. It requires that the input is a timestamp (not a string).

If your input is a string, use the Field() function to isolate the time component and StringToTime() to convert the format.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
praburaj
Premium Member
Premium Member
Posts: 133
Joined: Thu Jun 30, 2005 1:26 am
Location: philippines

Post by praburaj »

Thanks for your response.

I am receiving some data's are in below mentioned format

May 9 201 12:00AM It should be May 9 2011 12:00AM.

Like I mentioned above If I have any bad timestamp , I need to reject that data.
prabakaran.v
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

What is the data type of the source field? Where are you reading it from?
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
praburaj
Premium Member
Premium Member
Posts: 133
Joined: Thu Jun 30, 2005 1:26 am
Location: philippines

Post by praburaj »

My source column data type is String and I am reading from the SQL Server.
prabakaran.v
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

OK, you have two questions to answer. One can be a constraint expression.
(1) Is the incoming string valid as a timestamp with a four digit year (IsValid() function)?
(2) Convert the string to a timestamp then extract the time portion, or extract the time portion and convert it to a time data type.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
harishkumar.upadrasta
Participant
Posts: 18
Joined: Tue Dec 25, 2012 10:39 pm
Location: Detroit,MI

Post by harishkumar.upadrasta »

Hi Prabhu,

Please try this function.
IsValid('Date', StringToDate(<date Field>,"%yyyy%mm%dd") )=1 then its a valid date else its an invalid date.

Ray had put some comments, but i dont have a premium account i am not able to see it
Harish
venkateshrupineni
Participant
Posts: 15
Joined: Wed May 02, 2012 3:38 am

Post by venkateshrupineni »

Add to previous suggestions their is one more function IsValidTimestamp() try this it will genrate flag value, using this flag value u can filter the records
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Just to point out the obvious: "May 9 201 12:00AM" is a perfectly valid date/time, it's just... old. So your validation will need to be more than just a simple validation check but will need business value range checks, it would seem.
-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 »

... which is why I included "four digit year" in my specification.
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 »

Of course, just trying to point out that it may go beyond that.
-craig

"You can never have too many knives" -- Logan Nine Fingers
Post Reply