Jump to: navigation, search

Mysql SYSDATE

From w3cyberlearnings

Contents

MySQL SYSDATE Function

This function returns the current date and time as in 'YYYY-MM-DD HH:MM:SS' or YYYYMMDDHHMMSS.uuuuuu format, and it depends on whether it is a string or numeric context.

Syntax SYSDATE

SYSDATE()

SYSDATE() Vs. NOW() function

  • SYSDATE() function returns time at which it executes.
  • NOW() function returns a constant time.

Example 1

mysql> SELECT SYSDATE(),SLEEP(2),SYSDATE();
+---------------------+----------+---------------------+
| SYSDATE()           | SLEEP(2) | SYSDATE()           |
+---------------------+----------+---------------------+
| 2012-05-26 00:47:58 |        0 | 2012-05-26 00:48:00 | 
+---------------------+----------+---------------------+
1 row in set (2.00 sec)

Example 2

mysql> SELECT NOW(),SLEEP(2),NOW();
+---------------------+----------+---------------------+
| NOW()               | SLEEP(2) | NOW()               |
+---------------------+----------+---------------------+
| 2012-05-26 00:56:01 |        0 | 2012-05-26 00:56:01 | 
+---------------------+----------+---------------------+
1 row in set (2.00 sec)

Related Links



Navigation
Web
SQL
MISC
References