9951 explained code solutions for 126 technologies


clickhouseUsing dates with timezones


SELECT toDateTime(now(), 'Europe/Lisbon')ctrl + c
now()

returns current date/time

toDateTime

converts given string to DateTime

Europe/Lisbon

pass timezone to convert date/time to as a second argument


Usage example

SELECT toDateTime(now(), 'Europe/Lisbon')
output
┌─toDateTime(now(), 'Europe/Lisbon')─┐
│                2022-01-12 15:29:48 │
└────────────────────────────────────┘