- SQL Tutorial
- SQL - Home
- SQL - Overview
- SQL - RDBMS Concepts
- SQL - Databases
- SQL - Syntax
- SQL - Data Types
- SQL - Operators
- SQL - Expressions
- SQL Database
- SQL - Create Database
- SQL - Drop Database
- SQL - Select Database
- SQL - Rename Database
- SQL - Show Database
- SQL - Backup Database
- SQL Table
- SQL - Create Table
- SQL - Show Tables
- SQL - Rename Table
- SQL - Truncate Table
- SQL - Clone Tables
- SQL - Temporary Tables
- SQL - Alter Tables
- SQL - Drop Table
- SQL - Delete Table
- SQL - Constraints
- SQL Queries
- SQL - Insert Query
- SQL - Select Query
- SQL - Select Into
- SQL - Insert Into Select
- SQL - Update Query
- SQL - Delete Query
- SQL - Sorting Results
- SQL Views
- SQL - Create Views
- SQL - Update Views
- SQL - Drop Views
- SQL - Rename Views
- SQL Operators and Clauses
- SQL - Where Clause
- SQL - Top Clause
- SQL - Distinct Clause
- SQL - Order By Clause
- SQL - Group By Clause
- SQL - Having Clause
- SQL - AND & OR
- SQL - BOOLEAN (BIT) Operator
- SQL - LIKE Operator
- SQL - IN Operator
- SQL - ANY, ALL Operators
- SQL - EXISTS Operator
- SQL - CASE
- SQL - NOT Operator
- SQL - NOT EQUAL
- SQL - IS NULL
- SQL - IS NOT NULL
- SQL - NOT NULL
- SQL - BETWEEN Operator
- SQL - UNION Operator
- SQL - UNION vs UNION ALL
- SQL - INTERSECT Operator
- SQL - EXCEPT Operator
- SQL - Aliases
- SQL Joins
- SQL - Using Joins
- SQL - Inner Join
- SQL - Left Join
- SQL - Right Join
- SQL - Cross Join
- SQL - Full Join
- SQL - Self Join
- SQL - Delete Join
- SQL - Update Join
- SQL - Left Join vs Right Join
- SQL - Union vs Join
- SQL Keys
- SQL - Unique Key
- SQL - Primary Key
- SQL - Foreign Key
- SQL - Composite Key
- SQL - Alternate Key
- SQL Indexes
- SQL - Indexes
- SQL - Create Index
- SQL - Drop Index
- SQL - Show Indexes
- SQL - Unique Index
- SQL - Clustered Index
- SQL - Non-Clustered Index
- Advanced SQL
- SQL - Wildcards
- SQL - Comments
- SQL - Injection
- SQL - Hosting
- SQL - Min & Max
- SQL - Null Functions
- SQL - Check Constraint
- SQL - Default Constraint
- SQL - Stored Procedures
- SQL - NULL Values
- SQL - Transactions
- SQL - Sub Queries
- SQL - Handling Duplicates
- SQL - Using Sequences
- SQL - Auto Increment
- SQL - Date & Time
- SQL - Cursors
- SQL - Common Table Expression
- SQL - Group By vs Order By
- SQL - IN vs EXISTS
- SQL - Database Tuning
- SQL Function Reference
- SQL - Date Functions
- SQL - String Functions
- SQL - Aggregate Functions
- SQL - Numeric Functions
- SQL - Text & Image Functions
- SQL - Statistical Functions
- SQL - Logical Functions
- SQL - Cursor Functions
- SQL - JSON Functions
- SQL - Conversion Functions
- SQL - Datatype Functions
- SQL Useful Resources
- SQL - Questions and Answers
- SQL - Quick Guide
- SQL - Useful Functions
- SQL - Useful Resources
- SQL - Discussion
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
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 | @@DATEFIRST
This function is used to retrieve the first day of the week which is set by the SET DATEFIRST function. |
2 |
CURRENT_TIMESTAMP
Is used to retrieve the current date and time. |
3 | CURRENT_TIMEZONE()
This function is used to retrieve the current time zone offset from Coordinated Universal Time (UTC). |
4 | CURRENT_TIMEZONE_ID()
Is used to retrieve the current time zone ID observed by a server or an instance. |
5 | DATE_BUCKET()
Is used to group data into groups that correspond to fixed periods of time. |
6 | DATEADD()
Is used to add a specific number of intervals to a given date or time value. |
7 | DATEDIFF()
Is used to calculate the difference between two date values and returns in a int data type. |
8 | DATEDIFF_BIG()
Is used to calculate the difference between two dates values and return in a bigint data type. |
9 | DATEFROMPARTS()
This function is used to retrieve a date from individual segments such as year, month, and day. |
10 | DATENAME()
This function is used to retrieve a specified part of a date or time value as string. |
11 | DATEPART()
Is used to return a specified part of a date or time value as integer. |
12 | DATETIME2FROMPARTS()
Is used to construct a datetime2 value from an individual date and time segments. |
13 | DATETIMEFROMPARTS()
Is used to construct a datetime value from an individual date and time segments. |
14 | DATETIMEOFFSETFROMPARTS()
Is used to extract a datetimeoffset value from each of a date's component parts. |
15 | DATETRUNC()
Is used to truncate a date or time value to a specified datepart (such as year, month, day, etc.). |
16 | DAY()
This function is used to get the day of the month for a specified date. |
17 | EOMONTH()
This function is used to get the last day of the month for a specified date value. |
18 | GETDATE()
This function is used to get the current database system date and time. |
19 | GETUTCDATE()
This function is used to get the current database system UTC date and time. |
20 | ISDATE()
Is used to determine whether a value is a valid date or not. |
21 | MONTH()
This function is used to get the month part for a specified date (value can be from 1 to 12). |
22 | SMALLDATETIMEFROMPARTS()
Is used to construct a new datetime value from individual segments (such as year, month, etc.). |
23 | SWITCHOFFSET()
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 | SYSDATETIME()
This function is used to get the date and time of the SQL Server. |
25 | SYSDATETIMEOFFSET()
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 | SYSUTCDATETIME()
This function is used to get date and time of the computer on which the instance of SQL Server is running. |
27 | TIMEFROMPARTS()
Is used to construct a time value from individual segments. |
28 | TODATETIMEOFFSET()
This function is used to get a datetimeoffset value that is translated from a datetime2 expression. |
29 | YEAR()
This function is used to get an integer number that represents the year of the given date. |