pg_duration
pg_duration
pg_duration : data type for representing durations
Overview
| ID | Extension | Package | Version | Category | License | Language |
|---|---|---|---|---|---|---|
| 3830 | pg_duration
|
pg_duration
|
1.0.2 |
TYPE
|
MIT
|
C
|
| Attribute | Has Binary | Has Library | Need Load | Has DDL | Relocatable | Trusted |
|---|---|---|---|---|---|---|
--s-d-r
|
No
|
Yes
|
No
|
Yes
|
yes
|
no
|
| Relationships | |
|---|---|
| See Also | prefix
semver
unit
pgpdf
pglite_fusion
md5hash
asn1oid
roaringbitmap
|
Packages
| Type | Repo | Version | PG Major Compatibility | Package Pattern | Dependencies |
|---|---|---|---|---|---|
| EXT | PIGSTY
|
1.0.2 |
18
17
16
15
14
|
pg_duration |
- |
| RPM | PIGSTY
|
1.0.2 |
18
17
16
15
14
|
pg_duration_$v |
- |
| DEB | PIGSTY
|
1.0.2 |
18
17
16
15
14
|
postgresql-$v-pg-duration |
- |
| Linux / PG | PG18 | PG17 | PG16 | PG15 | PG14 |
|---|---|---|---|---|---|
el8.x86_64
|
PIGSTY 1.0.2
|
PIGSTY 1.0.2
|
MISS
|
MISS
|
MISS
|
el8.aarch64
|
PIGSTY 1.0.2
|
PIGSTY 1.0.2
|
MISS
|
MISS
|
MISS
|
el9.x86_64
|
PIGSTY 1.0.2
|
PIGSTY 1.0.2
|
MISS
|
MISS
|
MISS
|
el9.aarch64
|
PIGSTY 1.0.2
|
PIGSTY 1.0.2
|
MISS
|
MISS
|
MISS
|
el10.x86_64
|
PIGSTY 1.0.2
|
PIGSTY 1.0.2
|
MISS
|
MISS
|
MISS
|
el10.aarch64
|
PIGSTY 1.0.2
|
PIGSTY 1.0.2
|
MISS
|
MISS
|
MISS
|
d12.x86_64
|
PIGSTY 1.0.2
|
PIGSTY 1.0.2
|
MISS
|
MISS
|
MISS
|
d12.aarch64
|
PIGSTY 1.0.2
|
PIGSTY 1.0.2
|
MISS
|
MISS
|
MISS
|
d13.x86_64
|
PIGSTY 1.0.2
|
PIGSTY 1.0.2
|
MISS
|
MISS
|
MISS
|
d13.aarch64
|
PIGSTY 1.0.2
|
PIGSTY 1.0.2
|
MISS
|
MISS
|
MISS
|
u22.x86_64
|
PIGSTY 1.0.2
|
PIGSTY 1.0.2
|
MISS
|
MISS
|
MISS
|
u22.aarch64
|
PIGSTY 1.0.2
|
PIGSTY 1.0.2
|
MISS
|
MISS
|
MISS
|
u24.x86_64
|
PIGSTY 1.0.2
|
PIGSTY 1.0.2
|
MISS
|
MISS
|
MISS
|
u24.aarch64
|
PIGSTY 1.0.2
|
PIGSTY 1.0.2
|
MISS
|
MISS
|
MISS
|
Source
pig build pkg pg_duration; # build rpm/debInstall
Make sure PGDG and PIGSTY repo available:
pig repo add pgsql -u # add both repo and update cacheInstall this extension with pig:
pig install pg_duration; # install via package name, for the active PG version
pig install pg_duration -v 18; # install for PG 18
pig install pg_duration -v 17; # install for PG 17Create this extension with:
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.
Last updated on