Deals Of The Week - hours only!Up to 80% off on all courses and bundles.-Close
Introduction
Dealing with dates
Working with time data
Date and time date
Extracting dates and times
Doing arithmetic with dates
Converting date and time data
Current date and time data
Building date and time data from parts
Summary and review

Instruction

Let's start with the simplest, GETDATE(). This function returns a DATETIME data type, which has fewer fractional seconds and does not include time zone information. Therefore, it's less precise than other functions. Here's how you use this function:

SELECT GETDATE();

It is very simple, isn't it?

The CURRENT_TIMESTAMP function works exactly like GETDATE(). You don't use brackets with this function—only its name:

SELECT CURRENT_TIMESTAMP;

Why do we have two functions that do the same thing?

CURRENT_TIMESTAMP follows the ANSI SQL standard; GETDATE() is the T-SQL version.

It is important to mention that our database has the time zone set to UTC. This means that the time returned by these functions may differ from your local time.

Exercise

Run the template to check the current date and time.