Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>is you use different formats for the string then you can avoid this behaviour.</p> <p>There are 2 iso formats that are always specific -- sql server will always parse them in the same way regardless of the server date format setting.</p> <p>These are:</p> <p>1) Short form : YYYYMMDD. Example '20120301' -- 1st March 2012</p> <p>2) Long Form : YYYY-MM-DDTHH:MM:SS.msms'. Example '2012-03-01T12:13:00.000Z' -- 1st March 2012 at 13 minutes past 12 (PM)</p> <p>In the long form the miliseconds is optional -- this is a perfectly acceptable ISO datetime '2012-03-01T12:13:00Z'</p> <p>The Z at the end is time zone information. SQL Server doesn't actually require this. (though other products are a bit more exacting)</p> <p>Try this for example:</p> <pre><code>DECLARE @foo DATETIME SET DATEFORMAT DMY -- this will be the 3rd of january in DMY SET @foo = '2012-03-01' SELECT 'DMY: Not ISO', @foo SET @foo = '20120301' SELECT 'DMY: ISO', @foo SET DATEFORMAT MDY -- this will be the 1st of March in MDY SET @foo = '2012-03-01' SELECT 'MDY: not ISO', @foo SET @foo = '20120301' SELECT 'MDY: ISO', @foo </code></pre> <p>When you use text to enter dates you should <em>always</em> try to use one of the two ISO standards. It just makes things much more deterministic.</p> <p>Short format (SQL Server) <a href="http://msdn.microsoft.com/en-US/library/ms187085(v=sql.90).aspx" rel="nofollow">http://msdn.microsoft.com/en-US/library/ms187085(v=sql.90).aspx</a></p> <p>ISO 8601 Format (SQL Server) <a href="http://msdn.microsoft.com/en-us/library/ms190977(v=sql.90).aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/ms190977(v=sql.90).aspx</a></p>
    singulars
    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.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      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