Home > Database > Mysql Tutorial > body text

Mysql date_sub date_add函数用法_MySQL

WBOY
Release: 2016-06-01 13:29:28
Original
1459 people have browsed it

bitsCN.com

Mysql date_sub date_add函数用法

 

mysqldate_subdate_add

定义和用法

DATE_SUB() 函数从日期减去指定的时间间隔。

 

语法

DATE_SUB(date,INTERVAL expr type)

date 参数是合法的日期表达式。expr 参数是您希望添加的时间间隔。

type 参数可以是下列值:

 

Type 值MICROSECONDSECONDMINUTEHOURDAYWEEKMONTHQUARTERYEARSECOND_MICROSECONDMINUTE_MICROSECONDMINUTE_SECONDHOUR_MICROSECONDHOUR_SECONDHOUR_MINUTEDAY_MICROSECONDDAY_SECONDDAY_MINUTEDAY_HOURYEAR_MONTH
Copy after login

例如:

select f_id, date_sub(f_uptime, INTERVAL, 2, HOUR) from t_match ;update t_user_ticket set f_validtime = DATE_ADD(f_intime,INTERVAL 3 DAY)where f_ticket in (185, 186);
Copy after login

 


bitsCN.com
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!