mysql 查詢指定日期格式,使用 date_format(date,format) 函式
select date_format(create_date,"%y-%m-%d %h:%i%s") as create_date from table
select
date_format(a.submit_time, '%y') as name,
count(date_format(a.submit_time, '%y')) as value
from t_litigate_case a
where a.state = 1
group by date_format(a.submit_time, '%y')
%m 月名字(january……december)
%w 星期名字(sunday……saturday)
%d 有英語字首的月份的日期(1st, 2nd, 3rd, 等等。)
%y 年, 數字, 4 位
%y 年, 數字, 2 位
%a 縮寫的星期名字(sun……sat)
%d 月份中的天數, 數字(00……31)
%e 月份中的天數, 數字(0……31)
%m 月, 數字(01……12)
%c 月, 數字(1……12)
%b 縮寫的月份名字(jan……dec)
%j 一年中的天數(001……366)
%h 小時(00……23)
%k 小時(0……23)
%h 小時(01……12)
%i 小時(01……12)
%l 小時(1……12)
%i 分鐘, 數字(00……59)
%r 時間,12 小時(hh:mm:ss [ap]m)
%t 時間,24 小時(hh:mm:ss)
%s 秒(00……59)
%s 秒(00……59)
%p am或pm
%w 乙個星期中的天數(0=sunday ……6=saturday )
%u 星期(0……52), 這裡星期天是星期的第一天
%u 星期(0……52), 這裡星期一是星期的第一天
%% 乙個文字「%」
獲取當前系統時間
1.獲取當前日期+時間
now();
sysdate();
這兩個函式都是獲取日期+時間,不同之處在於:now()在執行開始時值就得到了,sysdate()在函式執行時動態得到值
mysql 固定日期 mysql查詢指定日期
1.今天 select from hb contract in h where to days modify date to days now 2.昨天 select from hb contract in h where to days now to days modify date 1 3.近七...
mysql查詢指定日期資料
查詢今天 select from 表名 where to days 時間欄位名 to days now 昨天 select from 表名 where to days now to days 時間欄位名 1 7天 select from 表名 where date sub curdate inter...
mysql指定日期加
mysql時間加減函式為date add date sub 定義和用法 date add 函式向日期新增指定的時間間隔。date sub 函式向日期減少指定的時間間隔。語法date add date,interval expr type date sub date,interval expr typ...