DATE TIME FUNCTION

Vaishali Goilkar
1 min readMay 24, 2020

In this article, we learn about Date Time Function in SQL Server.

CURRENT_TIMESTAMP

  • The CURRENT_TIMESTAMP function returns the current timestamp of the operating system. The returned timestamp is a DATETIME value without the time zone offset.
  • Syntax: CURRENT_TIMESTAMP

DATEADD

  • The DATEADD() function adds a time/date interval to date and then returns the date.
  • Syntax: DATEADD(interval, number, date)

DATEDIFF

  • The DATEDIFF() function returns the difference between two dates.
  • Syntax: DATEDIFF(interval, start_date , end_date)

DATENAME

  • The DATENAME() function returns a specified part of a date. It returns a string value.
  • Syntax: DATENAME(interval, date)

DATEPART

  • The DATEPART() function returns a specified part of a date. It returns an integer value.
  • Syntax: DATENAME(interval, date)

DAY

  • The DAY() function returns the day of the month (from 1 to 31) for a specified date.
  • Syntax: DAY(date)

GETDATE

  • The GETDATE() function returns the current database system date-time format.
  • Syntax: GETDATE()

GETUTCDATE

  • The GETUTCDATE() function returns the current database system UTC date-time format.
  • Syntax: GETUTCDATE()

MONTH

  • The MONTH() function returns the month part for a specified date.
  • Syntax: MONTH(date)

YEAR

  • The YEAR() function returns the year part for a specified date.
  • Syntax: YEAR(date)

If you are a newbie to database learning — SQL Server recommended is the following must-watch video: -

--

--