Wednesday, October 27, 2010

cast and convert for date - effect of sql server settings

1. This works :
select

2010-10-12

2. This doesnt work, because the string format is not compliant with the date format currently used by sql serverselect

Msg 241, Level 16, State 1, Line 1
Conversion failed when converting date and/or time from character string.

3. The following will work : select
2010-10-12
CONVERT(date , cast('10-12-2010' as datetime ) , 102)
CONVERT(date , '10-12-2010', 102)
CONVERT(date , '2010-10-12' , 102)

No comments:

Post a Comment

Misc Javascript points

 Nodejs can support multithreading through use of promises _ is the numeric separator for javascript, that means the numbers 10_000, 11.23_0...