ID06 psql

向前推一個小時(查詢前一個小時的內容):

create_time betweensql

to_timestamp(now()-interval '1 hour', 'yyyy-mm-dd hh24:00:00')oracle

andspa

to_timestamp(now(), 'yyyy-mm-dd hh24:00:00')date

 

 

以天進行分組:

select DATE_FORMAT(create_time,'%Y-%m-%d') as day1,count(1) from g_driver_counter_log where create_time>'2016-10-17 00:00:00' group by day1;
select time_key/10000 as day1,count(1) from isc_driver_counter_log where create_time>'2016-10-17 00:00:00' group by day1;select

 

 

時間格式化:

to_timestamp(now(),'yyyy-mm-dd HH24:MI:SS')im

psql 的to_date  (oracle的to_date返回是下面的圖2)查詢

select  to_date(create_time, 'yyyy-mm-dd HH24:MT:SS')  from  isc_driver_counter_log_dict where business_type in(26,27);dict

返回結果:img

select to_timestamp(create_time, 'yyyy-mm-dd HH24:MT:SS') from  isc_driver_counter_log_dict where business_type in(26,27);di

相關文章
相關標籤/搜索