How to Validate timestamp with milliseconds in Transformer

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
sharma
Premium Member
Premium Member
Posts: 46
Joined: Mon Dec 24, 2007 2:16 pm

How to Validate timestamp with milliseconds in Transformer

Post by sharma »

Hi,

I am getting timestamp string (varchar(17) ) with milliseconds.

Now using transformer i want to validate whether Timestamp is in correct format with correct value.

I am doing this:
If IsValid('TimeStamp', CL.crctn_dltn_ts) Then SetNull() Else "2010".

But its not validating milliseconds i.e it is returning null for all the below mentioned timestamp values.
Its only validating Timestamp upto 14 character and ignoring milliseconds part.
2010-12-21 10:10:10.123
2010-12-21 10:10:10 123
2010-12-21 10:10:10.abc
2010-12-21 10:10:10.123456

Please advise ASAP.

Regards
~Nirmal
Nirmal Sharma
priyadharsini
Participant
Posts: 40
Joined: Mon May 11, 2009 12:19 am
Location: Madurai

Post by priyadharsini »

Your timestamp string should be varchar(26) with milliseconds.
Convert Varchar to timestamp StringToTimestamp(i/p col,"%yyyy-%mm-%dd %hh:%nn:%ss.6")) and then apply the IsValid function
sridinesh2009
Participant
Posts: 14
Joined: Wed Nov 11, 2009 4:52 am
Location: New York

Post by sridinesh2009 »

use three stage variable.
sv1: validate date
sv2: validate time
sv3: validate micro seconds.
Dinesh.D
Ravi.K
Participant
Posts: 209
Joined: Sat Nov 20, 2010 11:33 pm
Location: Bangalore

Post by Ravi.K »

The Timestamp do not get fit in varchar(17). Use proper length.

The logic is based on your test data to validate whether it is Timestamp or not.

IsValid('Timestamp',StringToTimestamp(Inputcol,'%yyyy-%mm-%dd %hh:%nn:%ss.3))
Cheers
Ravi K
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

The point about IsValid() is that it tests a string. There's no point trying to apply StringToTimestamp() until and unless you're confident that the string contains a valid timestamp.
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