Which function returns the difference between two date/time values?

Prepare for your Database Systems Test. Use flashcards and multiple-choice questions, each question with hints and explanations. Ace your exam!

Multiple Choice

Which function returns the difference between two date/time values?

Explanation:
The main idea being tested is computing the time span between two date/time values, which is represented as an interval. The function that returns this difference is age. It takes two timestamps and yields the interval between them, for example age('2020-01-01', '2019-01-01') would produce a one-year interval. If you provide a single timestamp, age computes the difference between that moment and the current time, effectively age(timestamp) = age(timestamp, now()). Other options don’t provide a difference. Date_trunc rounds a timestamp down to a specified precision (like truncating to the start of the day or hour), so it doesn’t produce a duration. NOW simply yields the current date/time, not a difference. And make_date or make_time are constructors that build date/time values from parts, not calculations of differences.

The main idea being tested is computing the time span between two date/time values, which is represented as an interval. The function that returns this difference is age. It takes two timestamps and yields the interval between them, for example age('2020-01-01', '2019-01-01') would produce a one-year interval. If you provide a single timestamp, age computes the difference between that moment and the current time, effectively age(timestamp) = age(timestamp, now()).

Other options don’t provide a difference. Date_trunc rounds a timestamp down to a specified precision (like truncating to the start of the day or hour), so it doesn’t produce a duration. NOW simply yields the current date/time, not a difference. And make_date or make_time are constructors that build date/time values from parts, not calculations of differences.

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy