Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Invalid date
Message
From
17/07/2014 04:41:29
 
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Title:
Environment versions
SQL Server:
SQL Server 2014
Application:
Web
Miscellaneous
Thread ID:
01603774
Message ID:
01603883
Views:
59
>>Supplementary Question
>>
>>Anyway to stop a query failing if there is an invalid date encountered (replace it with NULL maybe )
>
>In SQL 2012 and up just use TRY_CAST instead of CAST().
>
>Otherwise use
>
>case when DateCol < '17530101' then NULL else cast(dateCol as DATETIME) end
Thanks Naomi
Previous
Reply
Map
View

Click here to load this message in the networking platform