IsValid for Time

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
altruist
Participant
Posts: 73
Joined: Thu May 11, 2006 6:50 am

IsValid for Time

Post by altruist »

Hi,

How can we check the validity of the below fields coming in as string from source

Code: Select all

Timestamp  --- IsValid('TIMESTAMP',InputField)
Timestamp (Microseconds)
Time
Time (Microseconds)
Thanks & Regards
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Check the documentation for that IsValid function. You would use a type of "timestamp" for the first two and "time" for the second two. And then the format string you would craft from the options noted here based on what your incoming string looks like.

Have you tried using it yet? Had any issues? If so please post both your input strings and your syntax with the results and we'll see if we can point you in the right direction.
-craig

"You can never have too many knives" -- Logan Nine Fingers
ssnegi
Participant
Posts: 138
Joined: Thu Nov 15, 2007 4:17 am
Location: Sydney, Australia

Post by ssnegi »

IsValid('Timestamp',DSLINK.INPUT,'%yyyy-%mm-%dd %hh:%nn:%ss.6')
IsValid('Time',DSLINK.INPUT,'%hh:%nn:%ss')
IsValid('Time',DSLINK.INPUT,'%hh:%nn:%ss.6')

You can change the format based on the input string
altruist
Participant
Posts: 73
Joined: Thu May 11, 2006 6:50 am

Post by altruist »

IsValid is not taking three arguments. I am using Datastage 8.1
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

What syntax does your version of the documentation show? I have 8.5 but not 8.1 handy.
-craig

"You can never have too many knives" -- Logan Nine Fingers
ssnegi
Participant
Posts: 138
Joined: Thu Nov 15, 2007 4:17 am
Location: Sydney, Australia

Post by ssnegi »

Code: Select all

if IsValid('Timestamp',field(DSLink.INPUT,'.',1)) and IsValid('int64',field(DSLink.INPUT,'.',2)) and len(field(DSLink.INPUT,'.',2)) <= 6 then @TRUE else @FALSE

IsValid('Time',DSLINK.INPUT) 

if IsValid('Time',field(DSLink.INPUT,'.',1)) and IsValid('int64',field(DSLink.INPUT,'.',2)) and len(field(DSLink.INPUT,'.',2)) <= 6 then @TRUE else @FALSE
Here I am assuming the the micro seconds are delimited from the timestamp by a '.' You can modify the field function depending on the delimiter.
Last edited by ssnegi on Mon May 05, 2014 9:53 pm, edited 1 time in total.
altruist
Participant
Posts: 73
Joined: Thu May 11, 2006 6:50 am

Post by altruist »

This is what I found in the documentation for IsValid

Description:Return whether the given string is valid for the given type. Valid types are ″date″, ″decimal″, ″dfloat″, ″sfloat″, ″int8″, ″uint8″, ″int16″, ″uint16″, ″int32″, ″uint32″, ″int64″, ″uint64″, ″raw″, ″string″, ″time″, ″timestamp″. ″ustring″
Arguments
type (string) format (string)
Output
result (int8)
ssnegi
Participant
Posts: 138
Joined: Thu Nov 15, 2007 4:17 am
Location: Sydney, Australia

Post by ssnegi »

In version 8.7 the IsValid function is of the type :

Code: Select all

IsValid(%typestring%,%valuestring%,[%format%])
This doesn't seem to be case in earlier version. So you can use the workaround code that I published earlier.
altruist
Participant
Posts: 73
Joined: Thu May 11, 2006 6:50 am

Post by altruist »

ssnegi wrote:

Code: Select all

if IsValid('Timestamp',field(DSLink.INPUT,'.',1)) and IsValid('int64',field(DSLink.INPUT,'.',2)) and len(field(DSLink.INPUT,'.',2)) <= 6 then @TRUE else @FALSE

IsValid('Time',DSLINK.INPUT) 

if IsValid('Time',field(DSLink.INPUT,'.',1)) and IsValid('int64',field(DSLink.INPUT,'.',2)) and len(field(DSLink.INPUT,'.',2)) <= 6 then @TRUE else @FALSE
Here I am assuming the the micro seconds are delimited from the timestamp by a '.' You can modify the field function depending on the delimiter.
While using the above syntax... it is not accepting format such as %mm/%dd/%yyyy %hh:%nn:%ss.6
ssnegi
Participant
Posts: 138
Joined: Thu Nov 15, 2007 4:17 am
Location: Sydney, Australia

Post by ssnegi »

convert the string %mm/%dd/%yyyy %hh:%nn:%ss.6
to desired format %yyyy-%mm-%dd %hh:%nn:%ss.6
using this derivation in stage variable:

Code: Select all

sv1 : 
DSLink.INPUT[7,4]:'-':DSLink.INPUT[1,2]:'-':DSLink.INPUT[4,2]:' ':field(DSLink.INPUT,' ',2)
Then apply IsValid Derivation in subsequent variable.

Code: Select all

sv2 :
If IsValid('Timestamp',field(sv1,'.',1)) and IsValid('int64',field(sv1,'.',2)) and len(field(sv1,'.',2)) <= 6 then @TRUE else @FALSE 
Post Reply