Time and window functions
We have seen how to represent a single moment in time using DuckDB’s TIMESTAMP
and TIMESTAMPTZ
data types. Now, let’s explore durations—the period of time that passes between timestamps—in an example as follows.
The Apollo 11 mission
Consider the chronology of events from the Apollo 11 mission, which was a historic achievement that marked the first time humans landed on the Moon. The mission was launched by NASA on July 16, 1969, and consisted of three spacecraft: the Command Module, the Service Module, and the Lunar Module. The crew of Apollo 11 included Neil Armstrong, Michael Collins, and Buzz Aldrin. The journey to the Moon took 4 days. On July 20, Armstrong and Aldrin separated the Lunar Module from the Command Module and descended to the lunar surface while Collins remained in orbit. At 20:17 UTC, the Lunar Module touched down on the Moon, and 6 hours later, Armstrong became the first human to step out of the Lunar Module...