Skip to main content

TO_YYYYMMDDHHMMSS

Convert a date or date with time (timestamp/datetime) to a UInt64 number containing the year and month number (YYYY * 10000000000 + MM * 100000000 + DD * 1000000 + hh * 10000 + mm * 100 + ss).

Syntax​

TO_YYYYMMDDHHMMSS(<expr>)

Arguments​

ArgumentsDescription
<expr>date/timestamp

Return Type​

BIGINT, returns in YYYYMMDDhhmmss format.

Examples​

SELECT
to_yyyymmddhhmmss('2023-11-12 09:38:18.165575');

┌─────────────────────────────────────────────────┐
│ to_yyyymmddhhmmss('2023-11-12 09:38:18.165575') │
├─────────────────────────────────────────────────┤
│ 20231112000000 │
└─────────────────────────────────────────────────┘

SELECT
to_yyyymmddhhmmss(to_timestamp('2023-11-12 09:38:18.165575'));

┌───────────────────────────────────────────────────────────────┐
│ to_yyyymmddhhmmss(to_timestamp('2023-11-12 09:38:18.165575')) │
├───────────────────────────────────────────────────────────────┤
│ 20231112093818 │
└───────────────────────────────────────────────────────────────┘
Try Databend Cloud for FREE

Multimodal, object-storage-native warehouse for BI, vectors, search, and geo.

Snowflake-compatible SQL with automatic scaling.

Sign up and get $200 in credits.

Try it today