pub fn daterange<lower, upper, bound>(
lower: lower,
upper: upper,
bound: bound,
) -> daterange<lower, upper, bound>where
lower: AsExpression<Nullable<Date>>,
upper: AsExpression<Nullable<Date>>,
bound: AsExpression<RangeBoundEnum>,
Available on crate feature
postgres_backend
only.Expand description
Returns range of dates
§Example
use diesel::dsl::daterange;
use diesel::pg::sql_types::RangeBound;
use time::{Date, macros::date};
diesel::insert_into(posts)
.values(&[
versions.eq(daterange(Some(date!(2020-01-01)), Some(date!(2021-01-01)), RangeBound::LowerBoundInclusiveUpperBoundInclusive)),
versions.eq(daterange(None, Some(date!(2020-01-01)), RangeBound::LowerBoundInclusiveUpperBoundExclusive)),
]).execute(conn)?;
let cool_posts = posts.select(versions)
.load::<(Bound<Date>, Bound<Date>)>(conn)?;
assert_eq!(vec![
(Bound::Included(date!(2020-01-01)), Bound::Excluded(date!(2021-01-02))),
(Bound::Unbounded, Bound::Excluded(date!(2020-01-01))),
], cool_posts);