MySQL Tutorial/Date Time Functions/SUBDATE — различия между версиями
Admin (обсуждение | вклад) м (1 версия) |
|
(нет различий)
|
Версия 13:44, 26 мая 2010
SELECT SUBDATE("1998-01-02", INTERVAL 31 DAY);
mysql>
mysql> SELECT SUBDATE("1998-01-02", INTERVAL 31 DAY);
+----------------------------------------+
| SUBDATE("1998-01-02", INTERVAL 31 DAY) |
+----------------------------------------+
| 1997-12-02 |
+----------------------------------------+
1 row in set (0.00 sec)
mysql>
mysql>
SUBDATE(date,INTERVAL expr unit)
The following table shows the expected form of the expr argument for each unit value.
unit 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"
SUBDATE(expr,days): The second form allows the use of an integer value for days
mysql>
mysql> SELECT SUBDATE("1998-01-02 12:00:00", 31);
+------------------------------------+
| SUBDATE("1998-01-02 12:00:00", 31) |
+------------------------------------+
| 1997-12-02 12:00:00 |
+------------------------------------+
1 row in set (0.00 sec)
mysql>
mysql>