When specifying dates in comparisons or for input to INSERT or UPDATE statements, use constants that are interpreted the same for all language settings:
- ADO, OLE DB, and ODBC applications should use the ODBC timestamp, date, and time escape clauses of:
{ ts 'yyyy-mm-dd hh:mm:ss[.fff] '} such as: { ts '1998-09-24 10:02:20' }
{ d 'yyyy-mm-dd'} such as: { d '1998-09-24' }
{ t 'hh:mm:ss'} such as: { t '10:02:20'}
- Applications using other APIs, or Transact-SQL scripts, stored procedures, and triggers should use the unseparated numeric strings for example: yyyymmdd as 19980924.
- Applications using other APIs, or Transact-SQL scripts stored procedures, and triggers can also use the CONVERT statement with an explicit style parameter for all conversions between the date and smalldate data types and character string data types. For example, this statement is interpreted the same for all language or date format connection settings:
SELECT *
FROM Northwind.dbo.Orders
WHERE OrderDate = CONVERT(DATETIME, '7/19/1996', 101)
For more information, see CAST and CONVERT.