Skip to main content

change_time_unit

Function change_time_unit 

Source
pub fn change_time_unit(
    input: Expression,
    unit: TimeUnit,
    rounding: TemporalRounding,
) -> Expression
Expand description

Convert a Date, Time, or Timestamp to a coarser unit with an explicit TemporalRounding.

unit must be coarser than the input unit and valid for the input type (a Date supports only days and milliseconds), or binding fails. At execution, TemporalRounding::Exact fails on a count with a remainder, and a Time fails when it rounds up to midnight, because the result must stay within the same day. A Timestamp keeps its time zone, and nulls stay null.