datetime - cast in sql server yyyy/mm/dd instead of dd/mm/yyyy -


i have script insert 1000 rows of data in table, in datetime column have information.

cast(n'2015-05-14 00:00:00.000' datetime) 

the problem cast trying cast in dd/mm/yyyy format input in yyyy/mm/dd format.

don't use cast when converting varchar datetime, use convert instead, convert takes in date format.

convert(datetime, '2015-05-14 00:00:00.000', 121) 

see more at:

http://www.sqlusa.com/bestpractices/datetimeconversion/

its written way since have generated script of data insert, cant change 1 one, many rows insert

are unable modify script? seems easy find/replace.

cast(n' -> convert(datetime, '

' datetime) -> ', 121)


Comments

Popular posts from this blog

OpenCV OpenCL: Convert Mat to Bitmap in JNI Layer for Android -

android - org.xmlpull.v1.XmlPullParserException: expected: START_TAG {http://schemas.xmlsoap.org/soap/envelope/}Envelope -

python - How to remove the Xframe Options header in django? -