SQL – Date Functions
The Date & time functions are built-in functions in the SQL server that allows you to manipulate and perform operations on date and time values in the SQL server.
These functions can be used in SQL Server queries to perform various date and time operations, such as filtering records based on dates, calculating date differences, and formatting dates for display purposes.
Sr.No. | Function & Description |
---|---|
1 |
This function is used to retrieve the first day of the week which is set by the SET DATEFIRST function. |
2 |
Is used to retrieve the current date and time. |
3 |
This function is used to retrieve the current time zone offset from Coordinated Universal Time (UTC). |
4 |
Is used to retrieve the current time zone ID observed by a server or an instance. |
5 |
Is used to group data into groups that correspond to fixed periods of time. |
6 |
Is used to add a specific number of intervals to a given date or time value. |
7 |
Is used to calculate the difference between two date values and returns in a int data type. |
8 |
Is used to calculate the difference between two dates values and return in a bigint data type. |
9 |
This function is used to retrieve a date from individual segments such as year, month, and day. |
10 |
This function is used to retrieve a specified part of a date or time value as string. |
11 |
Is used to return a specified part of a date or time value as integer. |
12 |
Is used to construct a datetime2 value from an individual date and time segments. |
13 |
Is used to construct a datetime value from an individual date and time segments. |
14 |
Is used to extract a datetimeoffset value from each of a date”s component parts. |
15 |
Is used to truncate a date or time value to a specified datepart (such as year, month, day, etc.). |
16 |
This function is used to get the day of the month for a specified date. |
17 |
This function is used to get the last day of the month for a specified date value. |
18 |
This function is used to get the current database system date and time. |
19 |
This function is used to get the current database system UTC date and time. |
20 |
Is used to determine whether a value is a valid date or not. |
21 |
This function is used to get the month part for a specified date (value can be from 1 to 12). |
22 |
Is used to construct a new datetime value from individual segments (such as year, month, etc.). |
23 |
This function is used to get datetimeoffset values that has been changed from the stored time zone offset to a given new time zone offset. |
24 |
This function is used to get the date and time of the SQL Server. |
25 |
This function is used to get a value of DATETIMEOFFSET(7) that provides the current system date and time and also timezone of the SQL server. |
26 |
This function is used to get date and time of the computer on which the instance of SQL Server is running. |
27 |
Is used to construct a time value from individual segments. |
28 |
This function is used to get a datetimeoffset value that is translated from a datetime2 expression. |
29 |
This function is used to get an integer number that represents the year of the given date. |