資料型別
資料型別
格式date
yyyy-mm-dd
datetime
yyyy-mm-dd hh:mm:ss
timestamp
yyyy-mm-dd hh:mm:ss
year
yyyy 或 yy
具體實現的函式
1、now() 返回當前的日期和時間
select now();
2、curdate() 返回當前的日期
select curdate();
3、curtime()返回當前的時間
select curtime();
4、date() 提取日期或日期/時間表示式的日期部分
select date('2016-08-12 15:33:22');
此外還有:
select time('2016-08-12 15:33:22'); -- 15:33:22
select year(@dt)、select quarter(@dt)、select month(@dt)、select week(@dt)、select day(@dt)、select hour(@dt)、select minute(@dt)、select second(@dt)
5、extract() 返回日期/時間按的單獨部分
select extract( year from '2016-08-12 15:33:22');
此外還有:select extract(quarter from @dt)、select extract(month from @dt)、select extract(week from @dt)、select extract(day from @dt)、 select extract(hour from @dt)、select extract(minute from @dt)、select extract(second from @dt)
6、date_format(date,format) 用不同的格式顯示日期/時間
select date_format('2016-08-12 15:33:22','%y/%m/%d')
mysql日期加減返回日 mysql日期加減
mysql日期加減 一 mysql 為日期增加乙個時間間隔 date add 1 示例 set dt now select date add dt,interval 1 day 加1天 select date add dt,interval 1 hour 加1小時 select date add d...
mysql8 0日期型別 MySQL的日期型別
mysql 中有多種資料型別可以用於日期和時間的表示,不同的版本可能有所差異,表 3 2 中 列出了 mysql 5.0 中所支援的日期和時間型別。表 3 2 mysql 中的日期和時間型別 日期和時間型別 位元組最小值 最大值date 1000 01 01 9999 12 31 datetime ...
mysql今天日期 MySQL獲取今天的日期
在本教程中,您將通過使用內建的日期函式來了解如何查詢獲取mysql今天的日期資料。使用內建日期函式獲取mysql今天的日期 有時,您可能希望從表中查詢資料,以獲取日期列為今天的日期,例如 select column list from table name where expired date to...