~drizzle-trunk/drizzle/development

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
CURRENT TIME FUNCTIONS
=======================


current_date
-------------

Returns the current date as a value in 'YYYY-MM-DD' or YYYYMMDD format, depending on whether the function is used in a string or numeric context.

.. code-block:: mysql

	SELECT CURDATE();
        	-> '2011-02-13'
	SELECT CURDATE() + 0;
        	-> 20110213

.. _now:

now()	                            
------

NOW returns the current date and time. The return value will be expressed as 'YYYY-MM-DD HH:MM:SS:mmmmmm' or YYYYMMDDHHMMSS.uuuuuu, depending on whether the function is used in a string or numeric context. The value is expressed in the current time zone.

.. code-block:: mysql

	SELECT NOW();
        	-> '2011-02-15 13:40:06:002203'
	SELECT NOW() + 0;
        	-> 20110215134006.002203

NOW returns a constant time that indicates the time at which the statement began to execute. 

.. code-block:: mysql

	SELECT NOW(), SLEEP(2), NOW();

Returns:

+----------------------------+----------+----------------------------+
| NOW()                      | SLEEP(2) | NOW()                      |
+============================+==========+============================+
| 2011-02-20 20:15:09:002203 |        0 | 2011-02-20 20:15:09:002203 |
+----------------------------+----------+----------------------------+

SYSDATE, however, returns the exact time at which the function was invoked.

.. code-block:: mysql

	SELECT SYSDATE(), SLEEP(2), SYSDATE();

Returns:

+---------------------+----------+---------------------+
| SYSDATE()           | SLEEP(2) | SYSDATE()           |
+=====================+==========+=====================+
| 2011-02-20 20:15:09 |        0 | 2011-02-20 20:15:11 |
+---------------------+----------+---------------------+

When using replication, the binary log will include SET TIMESTAMP entries so that a database can be restored from the binary log. In doing this, values from NOW will be adjusted to the same times as when the original SQL statements were executed. SYSDATE entries will be unaffected by SET TIMESTAMP entries.

current_timestamp
------------------

See :ref:`now`

CURRENT_TIMESTAMP() is a synonym for NOW(). 

localtime
-----------

See :ref:`now`

LOCALTIME() is a synonym for NOW(). 

localtimestamp	                   
---------------

See :ref:`now`

LOCALTIMESTAMP() is a synonym for NOW().