Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQL Server date formatting from string

Tags:

sql

sql-server

We've recently migrated our database to a different server and since this I think the date format querying has changed somehow.

Previously we could use the following..

SELECT * FROM table WHERE date > 'YYYY-MM-DD'

However now we have to use..

SELECT * FROM table WHERE date > 'YYYY-DD-MM'

Can someone tell me what I need to change to get back to the previous version?

like image 551
lisburnite Avatar asked Jul 09 '13 11:07

lisburnite


1 Answers

Try this one -

Query:

SET DATEFORMAT ymd

Read current settings:

DBCC USEROPTIONS

Output:

Set Option                 Value
-------------------------- -----------------
...
language                   us_english
dateformat                 ymd
...
like image 107
Devart Avatar answered Sep 23 '22 11:09

Devart