Reputation: 909
I have tried:
CAST(NULL AS DATETIME) AS Exit_T.
Give me the following error:
The conversion of a char data type to a datetime data type resulted in an out-of-range datetime value.
Are we able to assign null values to DateTime
fields? I need this after query hit some conditions
Upvotes: 0
Views: 4206
Reputation:
If datetime
field is a NULL
-able field, we can assign the NULL
values, otherwise, we can't able to assign the NULL
values.
See how the issue is not the cast, but must rather come from elsewhere:
select CASE(NULL AS DATETIME) AS Exit_T;
Upvotes: 1
Reputation: 570
What are you trying to do? You don't typically use NULL in a cast. You would assign the keyword NULL to the value of the field. Nulls are acceptable in DateTime fields if you allow it.
Upvotes: 2