Loading topic
DateStyle setting, and (for timestamptz) the session TimeZone setting. This chapter covers how those inputs combine, so that you can write literals that mean the same 4 min readCREATE TABLE and INSERT syntax, and know that UTC is a reference time and an offset like +02 is a distance from it. It builds on the overview of the date and time types. Here you will see what timestamptz holds on disk and why the 5 min readtimestamptz stores an instant (covered in the previous chapter) and that you can run queries in psql. Here you will learn the three ways PostgreSQL accepts a time zone, which one to choose, and the mistakes that follow from picking the wrong one.5 min readtimestamptz stores an absolute instant and that a UTC offset is the distance from UTC. Here you will learn where the TimeZone setting gets its value, how to change it, and which operations depend on it.5 min read+02 means "two hours ahead of UTC". You should have read the earlier chapters on timestamp versus timestamptz and on the session TimeZone s6 min readinterval is PostgreSQL's type for a length of time, such as "3 days" or "2 hours 30 minutes". It differs from timestamp and timestamptz, which mark a point on the timeline. This chapter assumes you know the date and time types, the session TimeZone setting, and basic timestamptz behavio4 min readtimestamptz, the session TimeZone setting, and intervals. It also assumes you know th6 min readextract, date_part, and date_trunc. These are the standard tools for answering questions like "which hour of the day?" and "which local day or month does this row belong to?". It assumes you know the difference between timestamp and timestamptz, that you know the sessio5 min readto_char, to_timestamp, to_date, and extract. It assumes you know the difference between timestamp and timestamptz, that the session TimeZone setting controls how timestamptz is displayed, and that AT TIME ZONE converts5 min readSELECT ... WHERE queries and that you know what timestamptz stores and how the session TimeZone setting affects it. It also assumes you have used AT TIME ZONE and date_trunc. Here you will apply them to the most common reporting task: selecting the 6 min readtimestamptz stores an instant, that the session TimeZone setting controls display, and that AT TIME ZONE converts in both directions. It covers where daylight saving time (DST) breaks code that otherwise looks correct, and how to write queries that stay corre5 min readgenerate_series produces a row for every step between two points. Range types store a start and an end as one value. It assumes you can already convert zones with AT TIME ZONE, do interval arithmetic, and write half-open (>= start, 5 min readtimestamp and timestamptz, how the session TimeZone setting affects output, how AT TIME ZONE converts values, and why half-open ranges work. Each rule below shows the bug it prevents.6 min read