Trait diesel::pg::expression::extensions::IntervalDsl [−][src]
A DSL added to integers and f64
to construct PostgreSQL intervals.
The behavior of these methods when called on NAN
or Infinity
, or when
overflow occurs is unspecified.
Examples
connection.execute("INSERT INTO users (name, created_at) VALUES ('Sean', NOW()), ('Tess', NOW() - '5 minutes'::interval), ('Jim', NOW() - '10 minutes'::interval)").unwrap(); let mut data: Vec<String> = users .select(name) .filter(created_at.gt(now - 7.minutes())) .load(&connection).unwrap(); assert_eq!(2, data.len()); assert_eq!("Sean".to_string(), data[0]); assert_eq!("Tess".to_string(), data[1]);
connection.execute("INSERT INTO users (name, created_at) VALUES ('Sean', NOW()), ('Tess', NOW() - '5 days'::interval), ('Jim', NOW() - '10 days'::interval)").unwrap(); let mut data: Vec<String> = users .select(name) .filter(created_at.gt(now - 7.days())) .load(&connection).unwrap(); assert_eq!(2, data.len()); assert_eq!("Sean".to_string(), data[0]); assert_eq!("Tess".to_string(), data[1]);
Required Methods
fn microseconds(self) -> PgInterval
[−]
Returns a PgInterval representing self
as microseconds
fn days(self) -> PgInterval
[−]
Returns a PgInterval representing self
in days
fn months(self) -> PgInterval
[−]
Returns a PgInterval representing self
in months
Provided Methods
fn milliseconds(self) -> PgInterval
[−]
Returns a PgInterval representing self
as milliseconds
fn seconds(self) -> PgInterval
[−]
Returns a PgInterval representing self
as seconds
fn minutes(self) -> PgInterval
[−]
Returns a PgInterval representing self
as minutes
fn hours(self) -> PgInterval
[−]
Returns a PgInterval representing self
as hours
fn weeks(self) -> PgInterval
[−]
Returns a PgInterval representing self
in weeks
Note: When called on a high precision float, the returned interval may be 1 microsecond different than the equivalent string passed to PostgreSQL.
fn years(self) -> PgInterval
[−]
Returns a PgInterval representing self
in weeks
Note: When called on a float, this method will mimic the behavior of PostgreSQL's interval parsing, and will ignore units smaller than months.
assert_eq!(1.08.years(), 1.year()); assert_eq!(1.09.years(), 1.year() + 1.month());
fn microsecond(self) -> PgInterval
[−]
Identical to microseconds
fn millisecond(self) -> PgInterval
[−]
Identical to milliseconds
fn second(self) -> PgInterval
[−]
Identical to seconds
fn minute(self) -> PgInterval
[−]
Identical to minutes
fn hour(self) -> PgInterval
[−]
Identical to hours
fn day(self) -> PgInterval
[−]
Identical to days
fn week(self) -> PgInterval
[−]
Identical to weeks
fn month(self) -> PgInterval
[−]
Identical to months
fn year(self) -> PgInterval
[−]
Identical to years
Implementations on Foreign Types
impl IntervalDsl for i32
[src]
impl IntervalDsl for i32
fn microseconds(self) -> PgInterval
[src]
fn microseconds(self) -> PgInterval
fn days(self) -> PgInterval
[src]
fn days(self) -> PgInterval
fn months(self) -> PgInterval
[src]
fn months(self) -> PgInterval
fn milliseconds(self) -> PgInterval
[src]
fn milliseconds(self) -> PgInterval
fn seconds(self) -> PgInterval
[src]
fn seconds(self) -> PgInterval
fn minutes(self) -> PgInterval
[src]
fn minutes(self) -> PgInterval
fn hours(self) -> PgInterval
[src]
fn hours(self) -> PgInterval
fn weeks(self) -> PgInterval
[src]
fn weeks(self) -> PgInterval
fn years(self) -> PgInterval
[src]
fn years(self) -> PgInterval
fn microsecond(self) -> PgInterval
[src]
fn microsecond(self) -> PgInterval
fn millisecond(self) -> PgInterval
[src]
fn millisecond(self) -> PgInterval
fn second(self) -> PgInterval
[src]
fn second(self) -> PgInterval
fn minute(self) -> PgInterval
[src]
fn minute(self) -> PgInterval
fn hour(self) -> PgInterval
[src]
fn hour(self) -> PgInterval
fn day(self) -> PgInterval
[src]
fn day(self) -> PgInterval
fn week(self) -> PgInterval
[src]
fn week(self) -> PgInterval
fn month(self) -> PgInterval
[src]
fn month(self) -> PgInterval
fn year(self) -> PgInterval
[src]
fn year(self) -> PgInterval
impl IntervalDsl for i64
[src]
impl IntervalDsl for i64
fn microseconds(self) -> PgInterval
[src]
fn microseconds(self) -> PgInterval
fn days(self) -> PgInterval
[src]
fn days(self) -> PgInterval
fn months(self) -> PgInterval
[src]
fn months(self) -> PgInterval
fn milliseconds(self) -> PgInterval
[src]
fn milliseconds(self) -> PgInterval
fn seconds(self) -> PgInterval
[src]
fn seconds(self) -> PgInterval
fn minutes(self) -> PgInterval
[src]
fn minutes(self) -> PgInterval
fn hours(self) -> PgInterval
[src]
fn hours(self) -> PgInterval
fn weeks(self) -> PgInterval
[src]
fn weeks(self) -> PgInterval
fn years(self) -> PgInterval
[src]
fn years(self) -> PgInterval
fn microsecond(self) -> PgInterval
[src]
fn microsecond(self) -> PgInterval
fn millisecond(self) -> PgInterval
[src]
fn millisecond(self) -> PgInterval
fn second(self) -> PgInterval
[src]
fn second(self) -> PgInterval
fn minute(self) -> PgInterval
[src]
fn minute(self) -> PgInterval
fn hour(self) -> PgInterval
[src]
fn hour(self) -> PgInterval
fn day(self) -> PgInterval
[src]
fn day(self) -> PgInterval
fn week(self) -> PgInterval
[src]
fn week(self) -> PgInterval
fn month(self) -> PgInterval
[src]
fn month(self) -> PgInterval
fn year(self) -> PgInterval
[src]
fn year(self) -> PgInterval
impl IntervalDsl for f64
[src]
impl IntervalDsl for f64
fn microseconds(self) -> PgInterval
[src]
fn microseconds(self) -> PgInterval
fn days(self) -> PgInterval
[src]
fn days(self) -> PgInterval
fn months(self) -> PgInterval
[src]
fn months(self) -> PgInterval
fn years(self) -> PgInterval
[src]
fn years(self) -> PgInterval
fn milliseconds(self) -> PgInterval
[src]
fn milliseconds(self) -> PgInterval
fn seconds(self) -> PgInterval
[src]
fn seconds(self) -> PgInterval
fn minutes(self) -> PgInterval
[src]
fn minutes(self) -> PgInterval
fn hours(self) -> PgInterval
[src]
fn hours(self) -> PgInterval
fn weeks(self) -> PgInterval
[src]
fn weeks(self) -> PgInterval
fn microsecond(self) -> PgInterval
[src]
fn microsecond(self) -> PgInterval
fn millisecond(self) -> PgInterval
[src]
fn millisecond(self) -> PgInterval
fn second(self) -> PgInterval
[src]
fn second(self) -> PgInterval
fn minute(self) -> PgInterval
[src]
fn minute(self) -> PgInterval
fn hour(self) -> PgInterval
[src]
fn hour(self) -> PgInterval
fn day(self) -> PgInterval
[src]
fn day(self) -> PgInterval
fn week(self) -> PgInterval
[src]
fn week(self) -> PgInterval
fn month(self) -> PgInterval
[src]
fn month(self) -> PgInterval
fn year(self) -> PgInterval
[src]
fn year(self) -> PgInterval