clickhouse日期类型转为字符类型

 

引用:  https://cloud.tencent.com/developer/article/1987036

 

--字符转日期
select '2022-01-05 09:58:00' str,toDate(str),toDateTime(str),toDate('2022-01-05')


--日期转字符
select now() dd,toYear(dd) "年",toQuarter(dd) "季度",toDayOfMonth(dd) "天",toDayOfWeek(dd) "星期",toHour(dd) "时"

select toDate('2022-08-05') dd,formatDateTime(dd,'%Y-%m-%d %H:%M:%S') "年-月-日 时:分:秒",formatDateTime(dd,'%Y%m') "年月",formatDateTime(dd,'%F')

 

posted @ 2022-08-05 10:22  江清风  阅读(5816)  评论(0编辑  收藏  举报