#sql #postgresql #interval

pg_interval

A native PostgreSQL interval type

9 unstable releases

0.4.4 Feb 15, 2026
0.4.3 Jan 31, 2026
0.4.2 Oct 20, 2022
0.4.1 Feb 23, 2022
0.0.1 Aug 6, 2018

#780 in Database interfaces

Download history 6131/week @ 2025-12-18 3882/week @ 2025-12-25 4211/week @ 2026-01-01 6457/week @ 2026-01-08 6610/week @ 2026-01-15 5003/week @ 2026-01-22 2709/week @ 2026-01-29 3854/week @ 2026-02-05 5963/week @ 2026-02-12 4067/week @ 2026-02-19 5778/week @ 2026-02-26 9880/week @ 2026-03-05 3748/week @ 2026-03-12 4302/week @ 2026-03-19 4149/week @ 2026-03-26 5028/week @ 2026-04-02

18,691 downloads per month
Used in 5 crates (4 directly)

MIT license

67KB
1.5K SLoC

Build Status codecov

Rust-Postgres-Interval

A interval type for the postgres driver.

Contributing

There is a separate document on how to contribute to this repo here

Overview

Rust-Postgres-Interval is dedicated datatype for the postgres interval type.

extern crate pg_interval;

use pg_interval::Interval;

fn main() {
    let interval = Interval::from_postgres(
        "1 years 1 months 1 days 1 hours"
    ).unwrap();
    let output = interval.to_iso_8601();
    assert_eq!(String::from("P1Y1M1DT1H"), output);
}

Requirements

  • rust 1.22

Roadmap to 1.0.0

  • Convert Interval Into Formated String
    • Iso 8601
    • Postgres
    • Sql
  • Parse Formated Strings Into The Interval Type
    • Iso 8601
    • Postgres
    • Sql
  • Chrono Integrations

Dependencies

~1–2MB
~34K SLoC