DATETRUNC()

DATETRUNC() 日期格式进行处理

select DATETRUNC(use_time,‘yyyymm’)
from dwm_stg_order_all_info
;

Datepart parameter of function DATETRUNC ‘yyyymm’ is not supported yet, we only support ‘[dd, mm, yyyy, mi, ss, year, month, mon, day, hour, hh, ff3, q, w]’ now.

select DATETRUNC(use_time,‘yyyy’)
from dwm_stg_order_all_info
;
2019-01-01 00:00:00
2019-01-01 00:00:00
2019-01-01 00:00:00
2019-01-01 00:00:00
2019-01-01 00:00:00
2019-01-01 00:00:00
2019-01-01 00:00:00

select DATETRUNC(use_time,‘mm’)
from dwm_stg_order_all_info
;
2019-12-01 00:00:00
2019-12-01 00:00:00
2019-12-01 00:00:00
2019-12-01 00:00:00
2019-12-01 00:00:00
2019-12-01 00:00:00

你可能感兴趣的:(SQL,sql)