top of page
Writer's pictureThe Tech Platform

Date Functions

This page lists the most commonly used SQL Server Date functions that allow you to handle date and time data effectively.


Returning the current date and time


Function Description

CURRENT_TIMESTAMP Returns the current system date and time without the time zone part.

GETUTCDATE Returns a date part of a date as an integer number.

GETDATE Returns the current system date and time of the operating system on

which the SQL Server is running.

SYSDATETIME Returns the current system date and time with more fractional

seconds precision than the GETDATE() function.

SYSUTCDATETIME Returns the current system date and time in UTC time

SYSDATETIMEOFFSET Returns the current system date and time with the time zone.



Returning the date and time Parts


Function Description

DATENAME Returns a date part of a date as a character string

DATEPART Returns a date part of a date as an integer number

DAY Returns the day of a specified date as an integer

MONTH Returns the month of a specified date as an integer

YEAR Returns the year of the date as an integer.



Returning a difference between two dates


Function Return value

DATEDIFF Returns a difference in date part between two dates.


Modifying dates


Function Description

DATEADD Adds a value to a date part of a date and return the new date value.

EOMONTH Returns the last day of the month containing the specified date, with

an optional offset.

SWITCHOFFSET Changes the time zone offset of a DATETIMEOFFSET value and

preserves the UTC value.

TODATETIMEOFFSET Transforms a DATETIME2 value into a DATETIMEOFFSET value.



Constructing date and time from their parts


Function Description

DATEFROMPARTS Return a DATE value from the year, month, and day

DATETIME2FROMPARTS Returns a DATETIME2 value from the date and time arguments

DATETIMEOFFSETFROMPARTS Returns a DATETIMEOFFSET value from the date and time

arguments

TIMEFROMPARTS Returns a TIME value from the time parts with the precisions


Validating date and time values


Function Description

ISDATE Check if a value is a valid date, time, or datetime value


Source: Guru99

0 comments

Comments


bottom of page