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
Invalid date
Moderators: chulett, rschirm, roy
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
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.
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.