0
0
PostgreSQLquery~5 mins

CURRENT_DATE, CURRENT_TIMESTAMP, NOW() in PostgreSQL - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What does the CURRENT_DATE function return in PostgreSQL?

CURRENT_DATE returns the current date from the system clock without the time part. It shows the year, month, and day only.

Click to reveal answer
beginner
How is CURRENT_TIMESTAMP different from CURRENT_DATE?

CURRENT_TIMESTAMP returns the current date and time including hours, minutes, seconds, and fractional seconds, while CURRENT_DATE returns only the date.

Click to reveal answer
beginner
What does the NOW() function return in PostgreSQL?

NOW() returns the current date and time, similar to CURRENT_TIMESTAMP. It shows the exact moment the query runs.

Click to reveal answer
intermediate
Can CURRENT_TIMESTAMP and NOW() return different values in the same query?

No, both CURRENT_TIMESTAMP and NOW() return the same timestamp value within a single query execution because they use the transaction start time.

Click to reveal answer
beginner
Why might you use CURRENT_DATE instead of CURRENT_TIMESTAMP or NOW()?

You use CURRENT_DATE when you only need the date without the time, for example, to record birthdays or due dates where time is not important.

Click to reveal answer
Which function returns only the date part without time in PostgreSQL?
AGETDATE()
BCURRENT_TIMESTAMP
CCURRENT_DATE
DNOW()
What does NOW() return in PostgreSQL?
ACurrent date and time
BCurrent time only
CCurrent date only
DCurrent timestamp without time zone
Are CURRENT_TIMESTAMP and NOW() different in PostgreSQL?
AYes, they return different times
BNo, they return the same timestamp
CCURRENT_TIMESTAMP returns date only
DNOW() returns date only
If you want to store only the date of a user's birthday, which function is best?
ACURRENT_DATE
BNOW()
CCURRENT_TIMESTAMP
DSYSDATE
Which of these is true about CURRENT_TIMESTAMP in PostgreSQL?
AIt returns only the date
BIt returns the current system time at call
CIt returns a random timestamp
DIt returns the time when the query started
Explain the difference between CURRENT_DATE, CURRENT_TIMESTAMP, and NOW() in PostgreSQL.
Think about what part of the date/time each function returns.
You got /4 concepts.
    When would you choose to use CURRENT_DATE instead of NOW() in your database queries?
    Consider situations where time details are unnecessary.
    You got /3 concepts.