ALTER FUNCTION Cdate
DECLARE @Outputdate as Smalldatetime
SET @Outputdate = CAST(@input as smalldatetime)
IF @@error = ''
SET @Outputdate = CAST('1/1/1900' as smalldatetime)
..trying to figure out how to "try" to cast a date, and if it errors out, then just return '1/1/1900'
I have lots of tables with lots of records .. where date of birth is not always proper.
I need to skip these records.. and can't get this working in a reliable way.
So far.. it bombs only on "out of range" dates.. and seems to be working for empty dates, and improperly formatted dates.