date_trunc

Function date_trunc 

Source
pub fn date_trunc<'a, V, P, E>(
    precision: P,
    expr: E,
) -> SQLExpr<'a, V, Timestamp, E::Nullable, Scalar>
where V: SQLParam + 'a, P: Expr<'a, V>, E: Expr<'a, V>, E::SQLType: Temporal,
Expand description

DATE_TRUNC - truncates a timestamp to specified precision (PostgreSQL).

Truncates the timestamp to the specified precision. Common values: ‘microseconds’, ‘milliseconds’, ‘second’, ‘minute’, ‘hour’, ‘day’, ‘week’, ‘month’, ‘quarter’, ‘year’, ‘decade’, ‘century’, ‘millennium’

Preserves the nullability of the input expression.

§Example

use drizzle_core::expr::date_trunc;

// SELECT DATE_TRUNC('month', users.created_at)
let month_start = date_trunc("month", users.created_at);