Skip to main content

DateTimeColExt

Trait DateTimeColExt 

Source
pub trait DateTimeColExt<T> {
    // Required methods
    fn year(&self) -> ColExpr<T>;
    fn month(&self) -> ColExpr<T>;
    fn day(&self) -> ColExpr<T>;
    fn hour(&self) -> ColExpr<T>;
    fn minute(&self) -> ColExpr<T>;
    fn second(&self) -> ColExpr<T>;
    fn week_day(&self) -> ColExpr<T>;
}
Expand description

Date-extract helpers — year(), month(), day().

Backend dispatch is hidden inside the returned ColExpr: the Postgres form uses CAST(EXTRACT(<part> FROM col) AS INTEGER); the SQLite form uses CAST(strftime('<fmt>', col) AS INTEGER). Both forms land in the same ColExpr; Predicate picks the right one at terminal time based on the resolved pool.

Required Methods§

Source

fn year(&self) -> ColExpr<T>

Year as an integer (e.g. 2026).

Source

fn month(&self) -> ColExpr<T>

Month of year, 1..=12.

Source

fn day(&self) -> ColExpr<T>

Day of month, 1..=31.

Source

fn hour(&self) -> ColExpr<T>

Hour of day, 0..=23.

Source

fn minute(&self) -> ColExpr<T>

Minute of hour, 0..=59.

Source

fn second(&self) -> ColExpr<T>

Second of minute, 0..=59 (whole seconds; subsecond fragments are truncated by the cast).

Source

fn week_day(&self) -> ColExpr<T>

Day of week. Numbering differs by backend to keep each dialect’s native form: Postgres EXTRACT(DOW ...) returns 0=Sunday..6=Saturday; SQLite strftime('%w', ...) matches that numbering too, so both backends agree. Use this for “rows posted on weekends” / “rows posted on a Friday” style queries — compare against the integer (week_day().eq(5) for Friday).

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§