mysql> SELECT DATE_ADD('2009-03-20', INTERVAL 31 DAY);
mysql> SELECT DATE_ADD('2009-03-20', INTERVAL 1 MONTH);
mysql> SELECT ADDDATE(CURDATE(), INTERVAL 31 DAY);
mysql> SELECT SUBDATE(CURDATE(), INTERVAL 2 MONTH);
La palabra clave INTERVAL
y el especificador type
no son sensibles a mayúsculas.
La siguiente tabla muestra cómo se relacionan los argumentos type
y expr
:
type Value | Expected expr Format |
MICROSECOND | MICROSECONDS |
SECOND | SECONDS |
MINUTE | MINUTES |
HOUR | HOURS |
DAY | DAYS |
WEEK | WEEKS |
MONTH | MONTHS |
QUARTER | QUARTERS |
YEAR | YEARS |
SECOND_MICROSECOND | 'SECONDS.MICROSECONDS' |
MINUTE_MICROSECOND | 'MINUTES.MICROSECONDS' |
MINUTE_SECOND | 'MINUTES:SECONDS' |
HOUR_MICROSECOND | 'HOURS.MICROSECONDS' |
HOUR_SECOND | 'HOURS:MINUTES:SECONDS' |
HOUR_MINUTE | 'HOURS:MINUTES' |
DAY_MICROSECOND | 'DAYS.MICROSECONDS' |
DAY_SECOND | 'DAYS HOURS:MINUTES:SECONDS' |
DAY_MINUTE | 'DAYS HOURS:MINUTES' |
DAY_HOUR | 'DAYS HOURS' |
YEAR_MONTH | 'YEARS-MONTHS' |
Referencias:
http://dev.mysql.com/doc/refman/5.0/es/date-and-time-functions.html
No comments:
Post a Comment