Deals Of The Week - hours only!Up to 80% off on all courses and bundles.-Close
Introduction
Dates
Time
Timestamps
Extract functions
Timezone conversion
Intervals
Current date and time
36. Current_date, current_time and current_timestamp
Review

Instruction

Good. Okay, let's move on – now we'll learn a practical application for intervals. But let's start from the beginning.

Our database knows the current date and time. It has three functions which can come in handy:

  • current_date returns the current date.
  • current_time return the current time.
  • current_timestamp returns the current date with time and timezone.

Note that we don't use parentheses () after the function name, even though we indeed use a function. You can use them in the following way:

SELECT current_date, current_time, current_timestamp;

Shall we give it a try?

Exercise

Run the template query and analyze the result.

The functions current_date, current_time, and current_timestamp return the current time for the database server (in our case: UTC). Depending on where you are, this may or may not be the same as your local time.