SQL Server Date and Time Functions

This page lists the commonly used date and time functions in SQL Server.

  1. DATEADD

    The DATEADD() function is a function in SQL Server used to add or subtract a specified time interval from a date.
  2. DATEDIFF

    The DATEDIFF() function in SQL Server is used to calculate the time difference between two dates, and can return results in units such as years, months, days, hours, minutes, and seconds.
  3. DATENAME

    The SQL Server DATENAME() function is used to return the name of a specified part of a date value.
  4. DATEPART

    The DATENAME() function is a date and time function in Microsoft SQL Server used to extract a specific part of a date or time, such as the year, month, hour, or minute.
  5. DAY

    In SQL Server, the DAY() function is used to extract the day of the month from a date expression.
  6. GETDATE

    In SQL Server, the GETDATE() function is used to return the current system date and time.
  7. HOUR

    In SQL Server, the HOUR() function is used to retrieve the hour part of a given time value.
  8. MINUTE

    In SQL Server, the MINUTE() function is used to extract the minute part of a time value.
  9. MONTH

    MONTH() is a date-time function in SQL Server used to return the month part of a given date.
  10. SECOND

    SECOND() is a built-in SQL Server function used to extract the seconds (0-59) part from a datetime value.
  11. SWITCHOFFSET

    The SWITCHOFFSET() function in SQL Server is used to change the time zone offset of a datetime value and returns the new datetime.
  12. SYSDATETIME

    The SYSDATETIME() function in SQL Server returns the current system date and time.
  13. SYSDATETIMEOFFSET

    In SQL Server, the SYSDATETIMEOFFSET() function returns the current system date and time along with the time zone offset from Coordinated Universal Time (UTC).
  14. SYSUTCDATETIME

    The SYSUTCDATETIME() function in SQL Server is used to return the current system UTC date and time value.
  15. TODATETIMEOFFSET

    InSQL Server, the TODATETIMEOFFSET() function allows combining a datetime value with a time zone offset value to create a DateTimeOffset value.
  16. YEAR

    The YEAR() function is one of the date and time functions in SQL Server, used to extract the year from a given date/time value.