9951 explained code solutions for 126 technologies


clickhouseHow to format date/time


SELECT formatDateTime(now(), '%Y, %d/%m %H:%M (:%S)')ctrl + c
now()

returns current date/time

formatDateTime

formats given date/time with a specified pattern

%Y

year

%d

day

%m

month

%H

hours

%M

minutes

%S

seconds


Usage example

SELECT formatDateTime(now(), '%Y, %d/%m %H:%M (:%S)')
output
┌─formatDateTime(now(), '%Y, %d/%m %H:%M (:%S)')─┐
│ 2022, 12/01 17:20 (:45)                        │
└────────────────────────────────────────────────┘