📣
TiDB Cloud Premium is now in public preview. Unlimited growth, instant elasticity, advanced security for enterprise workloads. Try it out →

TO_YYYYMMDD



Converts a date or date with time (timestamp/datetime) to a UInt32 number containing the year and month number (YYYY 10000 + MM 100 + DD).

Syntax

TO_YYYYMMDD(<expr>)

Arguments

ArgumentsDescription
<expr>date/datetime

Return Type

INT, returns in YYYYMMDD format.

Examples

SELECT to_yyyymmdd('2023-11-12 09:38:18.165575'); ┌───────────────────────────────────────────┐ │ to_yyyymmdd('2023-11-12 09:38:18.165575') │ ├───────────────────────────────────────────┤ │ 20231112 │ └───────────────────────────────────────────┘

Was this page helpful?