pg_duration
Overview
| Package | Version | Category | License | Language |
|---|---|---|---|---|
pg_duration | 1.0.2 | TYPE | MIT | C |
| ID | Extension | Bin | Lib | Load | Create | Trust | Reloc | Schema |
|---|---|---|---|---|---|---|---|---|
| 3830 | pg_duration | No | Yes | No | Yes | No | Yes | - |
| Related | prefix semver unit pgpdf pglite_fusion md5hash asn1oid roaringbitmap |
|---|
Version
| Type | Repo | Version | PG Ver | Package | Deps |
|---|---|---|---|---|---|
| EXT | PIGSTY | 1.0.2 | 1817161514 | pg_duration | - |
| RPM | PIGSTY | 1.0.2 | 1817161514 | pg_duration_$v | - |
| DEB | PIGSTY | 1.0.2 | 1817161514 | postgresql-$v-pg-duration | - |
| OS / PG | PG18 | PG17 | PG16 | PG15 | PG14 |
|---|---|---|---|---|---|
| el8.x86_64 | PIGSTY 1.0.2 el8.x86_64.pg18 : pg_duration_18 pg_duration_18-1.0.2-1PIGSTY.el8.x86_64.rpm
| PIGSTY 1.0.2 el8.x86_64.pg17 : pg_duration_17 pg_duration_17-1.0.2-1PIGSTY.el8.x86_64.rpm
| PIGSTY MISS | PIGSTY MISS | PIGSTY MISS |
| el8.aarch64 | PIGSTY 1.0.2 el8.aarch64.pg18 : pg_duration_18 pg_duration_18-1.0.2-1PIGSTY.el8.aarch64.rpm
| PIGSTY 1.0.2 el8.aarch64.pg17 : pg_duration_17 pg_duration_17-1.0.2-1PIGSTY.el8.aarch64.rpm
| PIGSTY MISS | PIGSTY MISS | PIGSTY MISS |
| el9.x86_64 | PIGSTY 1.0.2 el9.x86_64.pg18 : pg_duration_18 pg_duration_18-1.0.2-1PIGSTY.el9.x86_64.rpm
| PIGSTY 1.0.2 el9.x86_64.pg17 : pg_duration_17 pg_duration_17-1.0.2-1PIGSTY.el9.x86_64.rpm
| PIGSTY MISS | PIGSTY MISS | PIGSTY MISS |
| el9.aarch64 | PIGSTY 1.0.2 el9.aarch64.pg18 : pg_duration_18 pg_duration_18-1.0.2-1PIGSTY.el9.aarch64.rpm
| PIGSTY 1.0.2 el9.aarch64.pg17 : pg_duration_17 pg_duration_17-1.0.2-1PIGSTY.el9.aarch64.rpm
| PIGSTY MISS | PIGSTY MISS | PIGSTY MISS |
| el10.x86_64 | PIGSTY 1.0.2 el10.x86_64.pg18 : pg_duration_18 pg_duration_18-1.0.2-1PIGSTY.el10.x86_64.rpm
| PIGSTY 1.0.2 el10.x86_64.pg17 : pg_duration_17 pg_duration_17-1.0.2-1PIGSTY.el10.x86_64.rpm
| PIGSTY MISS | PIGSTY MISS | PIGSTY MISS |
| el10.aarch64 | PIGSTY 1.0.2 el10.aarch64.pg18 : pg_duration_18 pg_duration_18-1.0.2-1PIGSTY.el10.aarch64.rpm
| PIGSTY 1.0.2 el10.aarch64.pg17 : pg_duration_17 pg_duration_17-1.0.2-1PIGSTY.el10.aarch64.rpm
| PIGSTY MISS | PIGSTY MISS | PIGSTY MISS |
| d12.x86_64 | PIGSTY 1.0.2 d12.x86_64.pg18 : postgresql-18-pg-duration postgresql-18-pg-duration_1.0.2-1PIGSTY~bookworm_amd64.deb
| PIGSTY 1.0.2 d12.x86_64.pg17 : postgresql-17-pg-duration postgresql-17-pg-duration_1.0.2-1PIGSTY~bookworm_amd64.deb
| PIGSTY MISS | PIGSTY MISS | PIGSTY MISS |
| d12.aarch64 | PIGSTY 1.0.2 d12.aarch64.pg18 : postgresql-18-pg-duration postgresql-18-pg-duration_1.0.2-1PIGSTY~bookworm_arm64.deb
| PIGSTY 1.0.2 d12.aarch64.pg17 : postgresql-17-pg-duration postgresql-17-pg-duration_1.0.2-1PIGSTY~bookworm_arm64.deb
| PIGSTY MISS | PIGSTY MISS | PIGSTY MISS |
| d13.x86_64 | PIGSTY 1.0.2 d13.x86_64.pg18 : postgresql-18-pg-duration postgresql-18-pg-duration_1.0.2-1PIGSTY~trixie_amd64.deb
| PIGSTY 1.0.2 d13.x86_64.pg17 : postgresql-17-pg-duration postgresql-17-pg-duration_1.0.2-1PIGSTY~trixie_amd64.deb
| PIGSTY MISS | PIGSTY MISS | PIGSTY MISS |
| d13.aarch64 | PIGSTY 1.0.2 d13.aarch64.pg18 : postgresql-18-pg-duration postgresql-18-pg-duration_1.0.2-1PIGSTY~trixie_arm64.deb
| PIGSTY 1.0.2 d13.aarch64.pg17 : postgresql-17-pg-duration postgresql-17-pg-duration_1.0.2-1PIGSTY~trixie_arm64.deb
| PIGSTY MISS | PIGSTY MISS | PIGSTY MISS |
| u22.x86_64 | PIGSTY 1.0.2 u22.x86_64.pg18 : postgresql-18-pg-duration postgresql-18-pg-duration_1.0.2-1PIGSTY~jammy_amd64.deb
| PIGSTY 1.0.2 u22.x86_64.pg17 : postgresql-17-pg-duration postgresql-17-pg-duration_1.0.2-1PIGSTY~jammy_amd64.deb
| PIGSTY MISS | PIGSTY MISS | PIGSTY MISS |
| u22.aarch64 | PIGSTY 1.0.2 u22.aarch64.pg18 : postgresql-18-pg-duration postgresql-18-pg-duration_1.0.2-1PIGSTY~jammy_arm64.deb
| PIGSTY 1.0.2 u22.aarch64.pg17 : postgresql-17-pg-duration postgresql-17-pg-duration_1.0.2-1PIGSTY~jammy_arm64.deb
| PIGSTY MISS | PIGSTY MISS | PIGSTY MISS |
| u24.x86_64 | PIGSTY 1.0.2 u24.x86_64.pg18 : postgresql-18-pg-duration postgresql-18-pg-duration_1.0.2-1PIGSTY~noble_amd64.deb
| PIGSTY 1.0.2 u24.x86_64.pg17 : postgresql-17-pg-duration postgresql-17-pg-duration_1.0.2-1PIGSTY~noble_amd64.deb
| PIGSTY MISS | PIGSTY MISS | PIGSTY MISS |
| u24.aarch64 | PIGSTY 1.0.2 u24.aarch64.pg18 : postgresql-18-pg-duration postgresql-18-pg-duration_1.0.2-1PIGSTY~noble_arm64.deb
| PIGSTY 1.0.2 u24.aarch64.pg17 : postgresql-17-pg-duration postgresql-17-pg-duration_1.0.2-1PIGSTY~noble_arm64.deb
| PIGSTY MISS | PIGSTY MISS | PIGSTY MISS |
Build
You can build the RPM / DEB packages for pg_duration using pig build:
pig build pkg pg_duration # build RPM / DEB packages
Install
You can install pg_duration directly. First, make sure the PGDG and PIGSTY repositories are added and enabled:
pig repo add pgsql -u # Add repo and update cache
Install the extension using pig or apt/yum/dnf:
pig install pg_duration; # Install for current active PG version
pig ext install -y pg_duration -v 18 # PG 18
pig ext install -y pg_duration -v 17 # PG 17
dnf install -y pg_duration_18 # PG 18
dnf install -y pg_duration_17 # PG 17
apt install -y postgresql-18-pg-duration # PG 18
apt install -y postgresql-17-pg-duration # PG 17
Create Extension:
CREATE EXTENSION pg_duration;
Usage
The pg_duration extension provides a duration type for storing elapsed time as microseconds in 8 bytes, simpler and more consistently comparable than the built-in interval type.
CREATE EXTENSION pg_duration;
Data Type
The duration type represents absolute elapsed time without calendar components (no months or days). Valid input accepts any PostgreSQL interval syntax that does not exceed hourly units.
SELECT '01:30:00'::duration;
SELECT '2 hours 30 minutes'::duration;
Operators
- Arithmetic:
+,-between durations;*,/byfloat8; unary- - Comparison:
<,<=,>,>=,=,<>
Functions
-- Construct from components
SELECT make_duration(hours => 2, mins => 30, secs => 15.5);
-- Check for infinity
SELECT isfinite('01:00:00'::duration);
-- Truncate to precision
SELECT date_trunc('hour', '02:45:30'::duration);
-- Extract subfield
SELECT date_part('minute', '02:45:30'::duration);
SELECT extract_duration('hour', '02:45:30'::duration);
Type Conversions
Durations cast implicitly to interval. Converting interval to duration requires explicit casting.
Aggregates and Indexing
Standard aggregates (avg, count, max, min, sum) and both B-tree and hash indexes are supported.
Feedback
Was this page helpful?
Thanks for the feedback! Please let us know how we can improve.
Sorry to hear that. Please let us know how we can improve.