Introduction
Dates
Time
Timestamps
Extract functions
Timezone conversion
Intervals
Current date and time
36. Current_date, current_time and current_timestamp
Revision

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 use a function indeed. 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.

Console

Code editor

Result

TableConsole