Invalid date

Post questions here relative to DataStage Server Edition for such areas as Server job design, DS Basic, Routines, Job Sequences, etc.

Moderators: chulett, rschirm, roy

Post Reply
balaid
Participant
Posts: 7
Joined: Sun Aug 07, 2005 11:51 pm

Invalid date

Post by balaid »

I have a date column, In many of the rows it may be null or invalid date, if it an invalid date, I should place date()

Is there any function to do so...

can any one help me
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

There's no intrinsic function in server jobs, but you could easily write your own IsValidDate routine. It really depends on the number of possible invalid forms that you may have. For example:

Code: Select all

FUNCTION IsValidDate(TheDate)

Ans = Date()  ; * default value

If UnAssigned(TheDate) Or IsNull(TheDate)
Then
   GoTo MainExit
End

Ans = TheDate

* Check first for YMD order.
Temp1 = Iconv(TheDate, "DYMD")
Status1 = Status()

* This assumes that your locale specifies MDY order.
Temp2 = Iconv(TheDate, "DMDY")
Status2 = Status()

If Status1 <> 0 And Status2 <> 0
Then
   Ans = Oconv(Date(), "D-YMD[4,2,2]")
End

MainExit:
RETURN(Ans)
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