Date and Time Data Types and Functions - SQL Server (Transact-SQL) - Microsoft Learn PDF
Date and Time Data Types and Functions - SQL Server (Transact-SQL) - Microsoft Learn PDF
Applies to: SQL Server Azure SQL Database Azure SQL Managed Instance
Azure Synapse Analytics
The sections in this article cover all Transact-SQL date and time data types and functions.
through 9999-12-
31
23:59:59.9999999
7 Note
The Transact-SQL rowversion data type is not a date or time data type. timestamp is a
deprecated synonym for rowversion.
https://learn.microsoft.com/en-us/sql/t-sql/functions/date-and-time-data-types-and-functions-transact-sql?view=sql-server-ver16 2/8
2/5/23, 11:31 PM Date and Time Data Types and Functions - SQL Server (Transact-SQL) | Microsoft Learn
of the computer
on which the
instance of SQL
Server runs. The
returned value
doesn't include
the time zone
offset.
https://learn.microsoft.com/en-us/sql/t-sql/functions/date-and-time-data-types-and-functions-transact-sql?view=sql-server-ver16 3/8
2/5/23, 11:31 PM Date and Time Data Types and Functions - SQL Server (Transact-SQL) | Microsoft Learn
https://learn.microsoft.com/en-us/sql/t-sql/functions/date-and-time-data-types-and-functions-transact-sql?view=sql-server-ver16 4/8
2/5/23, 11:31 PM Date and Time Data Types and Functions - SQL Server (Transact-SQL) | Microsoft Learn
supplied for
date.
Functions that return date and time values from their parts
https://learn.microsoft.com/en-us/sql/t-sql/functions/date-and-time-data-types-and-functions-transact-sql?view=sql-server-ver16 5/8
2/5/23, 11:31 PM Date and Time Data Types and Functions - SQL Server (Transact-SQL) | Microsoft Learn
specified date
and time.
DATEDIFF DATEDIFF ( datepart, Returns the number of date or time int Deterministic
startdate, enddate ) datepart boundaries, crossed
between two specified dates.
EOMONTH EOMONTH ( Returns the last day of Return type is the Deterministic
start_date [, the month containing type of the
month_to_add ] ) the specified date, with start_date
an optional offset. argument, or
alternately, the
date data type.
SET DATEFIRST SET DATEFIRST { Sets the first day of the week to Not Not applicable
number | a number from 1 through 7. applicable
@number_var }
SET SET DATEFORMAT { Sets the order of the dateparts Not Not applicable
DATEFORMAT format | (month/day/year) for entering applicable
@format_var } datetime or smalldatetime
data.
SET LANGUAGE SET LANGUAGE { [ Sets the language environment Not Not applicable
N ] 'language' | for the session and system applicable
@language_var } messages. SET LANGUAGE isn't
a date or time function.
However, the language setting
affects the output of date
functions.
https://learn.microsoft.com/en-us/sql/t-sql/functions/date-and-time-data-types-and-functions-transact-sql?view=sql-server-ver16 7/8
2/5/23, 11:31 PM Date and Time Data Types and Functions - SQL Server (Transact-SQL) | Microsoft Learn
ISDATE ISDATE ( Determines whether a int ISDATE is deterministic only used with
expression ) datetime or smalldatetime the CONVERT function, when the
input expression has a valid CONVERT style parameter is specified,
date or time value. and when style isn't equal to 0, 100, 9,
or 109.
FORMAT Returns a value formatted with the specified format and optional culture. Use
the FORMAT function for locale-aware formatting of date/time and number
values as strings.
CAST and CONVERT Provides information about the conversion of date and time values to and from
(Transact-SQL) string literals, and other date and time formats.
Write International Provides guidelines for portability of databases and database applications that
Transact-SQL Statements use Transact-SQL statements from one language to another, or that support
multiple languages.
ODBC Scalar Functions Provides information about ODBC scalar functions available for use in Transact-
(Transact-SQL) SQL statements. This includes ODBC date and time functions.
See also
Functions
Data Types (Transact-SQL)
https://learn.microsoft.com/en-us/sql/t-sql/functions/date-and-time-data-types-and-functions-transact-sql?view=sql-server-ver16 8/8