關於mysql日期操作函式 date_formate 的使用
基本語法:
date_format(date,format)
說明:date 引數是合法的日期。format 規定日期/時間的輸出格式。
可以用的格式主要有
格式 描述
%a 縮寫星期名
%b 縮寫月名
%c 月,數值
%d 帶有英文本首的月中的天
%d 月的天,數值(00-31)
%e 月的天,數值(0-31)
%f 微秒
%h 小時 (00-23)
%h 小時 (01-12)
%i 小時 (01-12)
%i 分鐘,數值(00-59)
%j 年的天 (001-366)
%k 小時 (0-23)
%l 小時 (1-12)
%m 月名
%m 月,數值(00-12)
%p am 或 pm
%r 時間,12-小時(hh:mm:ss am 或 pm)
%s 秒(00-59)
%s 秒(00-59)
%t 時間, 24-小時 (hh:mm:ss)
%u 周 (00-53) 星期日是一周的第一天
%u 周 (00-53) 星期一是一周的第一天
%v 周 (01-53) 星期日是一周的第一天,與 %x 使用
%v 周 (01-53) 星期一是一周的第一天,與 %x 使用
%w 星期名
%w 周的天 (0=星期日, 6=星期六)
%x 年,其中的星期日是周的第一天,4 位,與 %v 使用
%x 年,其中的星期一是周的第一天,4 位,與 %v 使用
%y 年,4 位
%y 年,2 位
使用例項:
select
date_format(alarm_time, 『%y-%m-%d』) as 『x-x-x』,
date_format(alarm_time,』%y年%m月%d日』) as 『x年x月x日』,
date_format(alarm_time, 『%m-%d』) as 『x-x』,
date_format(alarm_time, 『%h時』) as 『x時』,
date_format(alarm_time, 『%h:%i:%s』) as 『xx:xx』
from
grid_alarm_info
where
grid_id = 『60089』
mysql學習筆記 51 mysql學習筆記
初學mysql時整理,隨時更新 資料操作 增 insert into 表名 字段列表 values 值列表 值列表 如果要插入的值列表包含所有字段並且順序一致,則可以省略字段列表。可同時插入多條資料記錄!replace 與 insert 完全一樣,可互換。insert into 表名 set 欄位名...
mysql學習筆記 51 Mysql 學習筆記
一.首先進入mysql mysql u root p新增使用者許可權設定 grant all privileges on to jerry localhost identified by aa1234567 只允許本機訪問 grant all privileges on to jerry 10.80...
mysql做筆記 mysql學習筆記
alter table 新增,修改,刪除表的列,約束等表的定義。檢視列 desc 表名 修改表名 alter table t book rename to bbb 新增列 alter table 表名 add column 列名 varchar 30 刪除列 alter table 表名 drop ...