Introduction

Date and Time plays major role in many projects. SQL Server has several date and time functions. In this article, we will discuss all the Date and Time functions in SQL Server with an Example.

CURRENT_TIMESTAMP()

Returns the date and time of the machine the SQL Server is running on.

EXAMPLE

SELECT CURRENT_TIMESTAMP AS [Current Date & Time];

DATEADD()

Adds a time or date interval to a date and then returns the date.

EXAMPLE

SELECT DATEADD(YEAR, 2, '2021/03/25') AS [Year Added];

SELECT DATEADD(MONTH, 2, '2021/03/25') AS [Month Added];

#sql server #sql

SQL Server Date Functions
1.10 GEEK