SQL Server - Select YEAR error -
currently using sql server 2008. in effort debug bad date data being processed, following code written example of bad data.
select isdate('10-22-002') select year('10-22-002')
running statements on database a, results are: '1' , '2002'.
running statements on database b, results are: '1' , error.
the date format mdy on sessions before running statements.
msg 241, level 16, state 1
conversion failed when converting datetime character string.
everything i'm able find says date format set @ either server or session level. there setting @ db level this?
you need cast '10-22-002'
datetime
.
select year(cast('10-22-002' datetime))
Comments
Post a Comment