Note that there are some explanatory texts on larger screens.

plurals
  1. POHow can I get SQL Server to use User Locale for Date format for a Query?
    primarykey
    data
    text
    <p>I have created the following simple table for this test:</p> <pre><code>DROP TABLE DateFieldTest CREATE TABLE DateFieldTest ( DateField Date NOT NULL ) INSERT INTO DateFieldTest VALUES ('2013-07-15') INSERT INTO DateFieldTest VALUES ('2013-07-16') INSERT INTO DateFieldTest VALUES ('2013-07-17') INSERT INTO DateFieldTest VALUES ('2013-07-05') INSERT INTO DateFieldTest VALUES ('2013-07-06') INSERT INTO DateFieldTest VALUES ('2013-07-07') INSERT INTO DateFieldTest VALUES ('2013-06-05') INSERT INTO DateFieldTest VALUES ('2013-06-06') INSERT INTO DateFieldTest VALUES ('2013-06-07') INSERT INTO DateFieldTest VALUES ('2013-05-05') INSERT INTO DateFieldTest VALUES ('2013-05-06') INSERT INTO DateFieldTest VALUES ('2013-05-07') SELECT * from DateFieldTest where DateField &gt;= '2013-07-05' SELECT * from DateFieldTest where DateField &gt;= '2013-07-06' SELECT * from DateFieldTest where DateField &gt;= '2013-07-07' SELECT * from DateFieldTest where DateField &gt;= '05/07/2013' SELECT * from DateFieldTest where DateField &gt;= '06/07/2013' SELECT * from DateFieldTest where DateField &gt;= '07/07/2013' SELECT * from DateFieldTest where DateField &gt;= '07/05/2013' SELECT * from DateFieldTest where DateField &gt;= '07/06/2013' SELECT * from DateFieldTest where DateField &gt;= '07/07/2013' SELECT * from DateFieldTest where DateField &gt;= '24/04/2013' </code></pre> <p>All the queries except the last one execute. The problem I have is that my different users have different date formats, and some users date format is dd/mm/yyyy, not the standard US/Canada of mm/dd/yyyyy. </p> <p>I know I can use the convert function to cast a date, but I am working with older queries and software that is simply using the date entered by the user. I want to know how to instruct SQL Server 2005+ to use the user's Short Date format in their locale.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload