Trait block_tools::db::use_diesel::dsl::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
pub fn microseconds(self) -> PgInterval
[src]
Returns a PgInterval representing self
as microseconds
pub fn days(self) -> PgInterval
[src]
Returns a PgInterval representing self
in days
pub fn months(self) -> PgInterval
[src]
Returns a PgInterval representing self
in months
Provided methods
pub fn milliseconds(self) -> PgInterval
[src]
Returns a PgInterval representing self
as milliseconds
pub fn seconds(self) -> PgInterval
[src]
Returns a PgInterval representing self
as seconds
pub fn minutes(self) -> PgInterval
[src]
Returns a PgInterval representing self
as minutes
pub fn hours(self) -> PgInterval
[src]
Returns a PgInterval representing self
as hours
pub fn weeks(self) -> PgInterval
[src]
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.
pub fn years(self) -> PgInterval
[src]
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());
pub fn microsecond(self) -> PgInterval
[src]
Identical to microseconds
pub fn millisecond(self) -> PgInterval
[src]
Identical to milliseconds
pub fn second(self) -> PgInterval
[src]
Identical to seconds
pub fn minute(self) -> PgInterval
[src]
Identical to minutes
pub fn hour(self) -> PgInterval
[src]
Identical to hours
pub fn day(self) -> PgInterval
[src]
Identical to days
pub fn week(self) -> PgInterval
[src]
Identical to weeks
pub fn month(self) -> PgInterval
[src]
Identical to months
pub fn year(self) -> PgInterval
[src]
Identical to years