1. Learn
  2. /
  3. Courses
  4. /
  5. Functions for Manipulating Data in PostgreSQL

Connected

Exercise

Working with the current date and time

Because the Sakila database is a bit dated and most of the date and time values are from 2005 or 2006, you are going to practice using the current date and time in our queries without using Sakila. You'll get back into working with this database in the next video and throughout the remainder of the course. For now, let's practice the techniques you learned about so far in this chapter to work with the current date and time.

As you learned in the video, NOW() and CURRENT_TIMESTAMP can be used interchangeably.

Instructions 1/4

undefined XP
  • 1

    Use NOW() to select the current timestamp with timezone.

  • 2

    Select the current date without any time value.

  • 3

    Now, let's use the CAST() function to eliminate the timezone from the current timestamp.

  • 4
    • Finally, let's select the current date.
    • Use CAST() to retrieve the same result from the NOW() function.