Page 1 of 1
Invalid date
Posted: Thu Aug 11, 2005 10:49 pm
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
Posted: Fri Aug 12, 2005 12:06 am
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)