validate YYYYMMDD and HHMMSS

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
ingsic
Participant
Posts: 6
Joined: Tue Apr 14, 2009 11:06 am
Location: cali
Contact:

validate YYYYMMDD and HHMMSS

Post by ingsic »

Need to validate
if the following formats are correct:


YYYYMMDD
Date:
if isValid ('DATE', StringToDate (StageVar, "% yyyy% mm% dd")) Then StageVar else 0

HHMMSS
Time

isvalid (HH: MM: SS)

Please confirm if it is correct
eph
Premium Member
Premium Member
Posts: 110
Joined: Mon Oct 18, 2010 10:25 am

Post by eph »

ingsic
Participant
Posts: 6
Joined: Tue Apr 14, 2009 11:06 am
Location: cali
Contact:

Post by ingsic »

ok

but yet need to validate if the following formats are correct:

HHMMSS

isvalid (HH: MM: SS)

thanks
jwiles
Premium Member
Premium Member
Posts: 1274
Joined: Sun Nov 14, 2004 8:50 pm
Contact:

Post by jwiles »

IsValid("time",timestring)

Where timestring is in the format HH:MM:DD (or the default format if different).

Regards,
- james wiles


All generalizations are false, including this one - Mark Twain.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Code: Select all

IsValid(inLink.TheTimeString, "%hh%nn%ss")
will be appropriate if there are no delimiters.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
jwiles
Premium Member
Premium Member
Posts: 1274
Joined: Sun Nov 14, 2004 8:50 pm
Contact:

Post by jwiles »

For 8.1? Not FP1, at least
- james wiles


All generalizations are false, including this one - Mark Twain.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

For 8.0.1 (at least according to the manual) and therefore, presumably, for 8.1.
Parallel Job Developer's Guide (8.0) wrote:result (int8) = IsValid(type (string) [, format (string)])
(page 601)
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
jwiles
Premium Member
Premium Member
Posts: 1274
Joined: Sun Nov 14, 2004 8:50 pm
Contact:

Post by jwiles »

The 8.1 docs have the same entry (and so do the 7.5.1a docs), but I think it was a typo that never got corrected. It should be (IMHO)

Code: Select all

result (int8) = IsValid(type (string), string (string))
With type being one of the datatypes and string being the value being validated. At least that is what the transformer derivation validator allows.

When I run this derivation:

Code: Select all

IsValid("120101","%hh%nn%ss")
I get this message and a result of 0:

Code: Select all

APT_CombinedOperatorController,1: Expected identifier; got: "120101"
That's on two different 8.1 FP1 systems, one RedHat and one AIX.

c'est la vie :?
- james wiles


All generalizations are false, including this one - Mark Twain.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

D'accord.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
jwiles
Premium Member
Premium Member
Posts: 1274
Joined: Sun Nov 14, 2004 8:50 pm
Contact:

Post by jwiles »

I tried the third option in 8.1 as well and it wouldn't pass validation.
- james wiles


All generalizations are false, including this one - Mark Twain.
ingsic
Participant
Posts: 6
Joined: Tue Apr 14, 2009 11:06 am
Location: cali
Contact:

validate

Post by ingsic »

jwiles wrote:I tried the third option in 8.1 as well and it wouldn't pass validation.
isvalid('DATE',StringToDate(Lnk_campo,"%yyyy%mm%dd"))

isvalid('TIME',StringToTime(Lnk_encabezado.CHDHTR_E,"%hh%nn%ss"))
jwiles
Premium Member
Premium Member
Posts: 1274
Joined: Sun Nov 14, 2004 8:50 pm
Contact:

Post by jwiles »

Those work, but mainly because Date, Time and Timestamp datatypes return a string of asterisks '*' when the data is invalid. In a sense, the datatype is performing the validation for you.
- james wiles


All generalizations are false, including this one - Mark Twain.
Post Reply