MySQL时间函数
2016-11-11 00:00
10 查看
/*字符串转日期 Y=4位年,y=2位年,H=24时制,h=12时制,m=月,d=日,i=分,s=秒*/ select str_to_date('2016-11-11 11:36:00', '%Y-%m-%d %H:%i:%s'); /*result:2016-11-11 11:36:00*/ /*日期格式化 u=周*/ select date_format(now(), '%y-%m-%d %h:%i:%s-今年第%u周'); /*result:16-11-11 11:49:24-今年第45周*/ /*转成时间戳*/ select timestamp('2016-11-11'); /*result:2016-11-11 00:00:00*/ /*取年月日*/ select date('2016-11-11 11:36:00'); /*result:2016-11-11*/ /*取年*/ select year(now()); /*result:2016*/ /*取月*/ select month(now()); /*result:11*/ /*取日*/ select day('2016-11-12'); /*result:12*/ /*取时分秒*/ select time('2016-11-11 11:36:00'); /*result:11:36:00*/ /*取当前时分秒*/ select curtime(); /*result:11:51:47*/ /*取当前日期*/ select curdate(); /*result:2016-11-11*/ /*取当前日期2*/ select current_date; /*result:2016-11-11*/ /*取当前时分秒2*/ select current_time; /*result:11:52:47*/ /*取当前时间戳*/ select current_timestamp; /*result:2016-11-11 11:53:02*/ /*时间运算*/ /*日——*/ select date_add(now(), interval 1 day); /*result:2016-11-12 11:59:34*/ /*时+1*/ select date_add(now(), interval 1 hour); /*result:2016-11-11 12:59:41*/ /*月+1*/ select date_add(now(), interval 1 month); /*result:2016-12-11 11:59:50*/
相关文章推荐
- Mysql日期和时间函数
- Mysql日期和时间函数大全
- Mysql日期和时间函数
- MySQL时间函数tips
- MySql 时间函数用法集合
- [转载]MySQL日期和时间函数不求人
- Mysql日期和时间函数大全
- Mysql中一些要用到的日期和时间函数
- Mysql日期和时间函数不求人
- mysql中的日期和时间函数
- Mysql日期和时间函数不求人
- Mysql日期和时间函数不求人
- mysql的日期和时间函数
- Mysql日期和时间函数不求人
- Mysql日期和时间函数大全
- Mysql日期和时间函数
- Mysql日期和时间函数
- MySQL:日期和时间函数
- Mysql日期和时间函数不求人
- mysql 时间函数用法 集合