Skip to main content

strftime

Function strftime 

Source
pub fn strftime<'a, V, F, E>(
    format: F,
    expr: E,
) -> SQLExpr<'a, V, <V::DialectMarker as DialectTypes>::Text, E::Nullable, <F::Aggregate as AggregateKind>::Or<E::Aggregate>, (F::Sources, E::Sources)>
where V: SQLParam + 'a, V::DialectMarker: DialectSupports<SQLiteDateTime>, F: Expr<'a, V>, F::SQLType: Textual, E: Expr<'a, V>, E::SQLType: Temporal,
Expand description

Formats a time value as text (STRFTIME(format, expr)), on SQLite.

format must be text and expr temporal. The result is text and keeps expr’s nullability. Common format codes:

  • %Y year, %m month (01-12), %d day (01-31)
  • %H hour (00-23), %M minute, %S second
  • %s Unix time, %w weekday (0-6, Sunday is 0), %j day of year

§Examples

let day = strftime("%Y-%m-%d", users.created_at);
assert_eq!(day.sql(), r#"STRFTIME (?, "users"."created_at")"#);