strftime

Function strftime 

Source
pub fn strftime<'a, V, F, E>(
    format: F,
    expr: E,
) -> SQLExpr<'a, V, Text, E::Nullable, Scalar>
where V: SQLParam + 'a, F: Expr<'a, V>, E: Expr<'a, V>, E::SQLType: Temporal,
Expand description

STRFTIME - formats a temporal expression as text (SQLite).

Returns Text type, preserves nullability of the time value.

§Format Specifiers (common)

  • %Y - 4-digit year
  • %m - month (01-12)
  • %d - day of month (01-31)
  • %H - hour (00-23)
  • %M - minute (00-59)
  • %S - second (00-59)
  • %s - Unix timestamp
  • %w - day of week (0-6, Sunday=0)
  • %j - day of year (001-366)

§Example

use drizzle_core::expr::strftime;

// SELECT STRFTIME('%Y-%m-%d', users.created_at)
let formatted = strftime("%Y-%m-%d", users.created_at);