Everyone at one time or another has seen errors when converting a numeric field to a date using CVTDATE. This is most likely caused by a zero value in the date (numeric) field.

An old trick was to substitute a date such as 1/1/1940 using CASE to condition on the zero date. The newer option--Valid_Date--is very useful in this situation. A calculation like this:

CASE WHEN valid_date(invdte,"*ymd")=1 THEN char(cvtdate(invdte,ymd1)) ELSE " " END 

will return a blank if the date in not valid.

*YMD is one of many formats supported by the Valid_Date function.


Still have questions? We can help. Submit a case to Technical Support.

Last Modified On: April 21, 2017