Functions for working with date and time once long 10000 1000 datetime_transform toSecond toMinute toHour toDayOfWeek toDayOfMonth toMonth toYear toStartOfMinute toStartOfFiveMinute toStartOfFifteenMinutes toStartOfHour toStartOfDay toDate toMonday toStartOfMonth toStartOfQuarter toYear toTime toRelativeYearNum toRelativeMonthNum toRelativeWeekNum toRelativeDayNum toRelativeHourNum toRelativeMinuteNum toRelativeSecondNum toYYYYMM toYYYYMMDD toYYYYMMDDhhmmss date_transform toDayOfWeek toDayOfMonth toMonth toYear toStartOfDay toDate toMonday toStartOfMonth toStartOfQuarter toYear toRelativeYearNum toRelativeMonthNum toRelativeWeekNum toRelativeDayNum toYYYYMM toYYYYMMDD toYYYYMMDDhhmmss time_zone UTC Europe/Moscow Asia/Kolkata SELECT count() FROM system.numbers WHERE NOT ignore(toDateTime('2017-01-01 00:00:00') + number % 100000000 + rand() % 100000 AS t, {datetime_transform}(t, '{time_zone}')) SELECT count() FROM system.numbers WHERE NOT ignore(toDate('2017-01-01') + number % 1000 + rand() % 10 AS t, {date_transform}(t))