List of Date and Time Functions in SQL Server (T-SQL)

This post contains a list of Transact-SQL date and time functions available in SQL Server (as of SQL Server 2017).

This includes functions that return the date or parts of the date, as well as functions that manipulate and/or format the date.

System Date/Time Values

The following functions return the system date and time. The date/time values returned by these functions are all derived from the operating system that the instance of SQL Server runs on.

Higher precision

Lower precision

Return Date/Time Parts

These functions return the applicable part of the date that you specify, from the date that you specify.

For example, you can use MONTH() to return the month component of the given date.

Return a Date/Time Value from its Parts

These functions allow to you build a date and/or time value from the various parts that make up the date/time. Simply provide the various parts, and the function will return the date/time in the applicable data type.

For example, you can pass the year, month, and day values to the DATEFROMPARTS() function, and it will return a date value consisting of those parts.

Return the Difference Between Two Date/Time Values

The following functions can be used to return the difference between two different date/time values.

  • DATEDIFFdatepart , startdate , enddate )
  • DATEDIFF_BIGdatepart , startdate , enddate )

Note that these functions do essentially the same thing. The difference is in the return value.

Modify Date/Time Values

Set or Return Session Format Functions

Validate a Date/Time Value

This function allows you to verify whether the argument passed to it has a valid date or time value.

Related Functions/Articles