Jump to: navigation, search

Mysql SUBTIME

From w3cyberlearnings

Contents

MySQL SUBTIME Function

This function returns the substration of a give time. It returns the value the same format as in the first argument (expre1).

Syntax SUBTIME

  • expre1: time or datetime expression
  • expre2: time, minute, or second
SUBTIME(expre1, expres2);

Example 1: substract from time

ysql> SELECT SUBTIME('2012-12-03 04:34:33','05:34:44');
+-------------------------------------------+
| SUBTIME('2012-12-03 04:34:33','05:34:44') |
+-------------------------------------------+
| 2012-12-02 22:59:49                       |
+-------------------------------------------+
1 row in set (0.00 sec)

Example 2

mysql> SELECT SUBTIME('04:34:33','05:34:44');
+--------------------------------+
| SUBTIME('04:34:33','05:34:44') |
+--------------------------------+
| -01:00:11                      |
+--------------------------------+
1 row in set (0.00 sec)

Example 3: substract from second

mysql> SELECT SUBTIME('2012-12-03 04:34:33',2);
+----------------------------------+
| SUBTIME('2012-12-03 04:34:33',2) |
+----------------------------------+
| 2012-12-03 04:34:31              |
+----------------------------------+
1 row in set (0.00 sec)

Related Links



Navigation
Web
SQL
MISC
References