Oracle 5.0 Reference Manual page 948

Table of Contents

Advertisement

Range checking on the parts of date values is as described in
DATETIME, and
TIMESTAMP
values of 0 are permitted unless the SQL mode is set to disallow such values.
mysql>
SELECT STR_TO_DATE('00/00/0000', '%m/%d/%Y');
-> '0000-00-00'
mysql>
SELECT STR_TO_DATE('04/31/2004', '%m/%d/%Y');
-> '2004-04-31'
Note
You cannot use format
because the combination of a year and week does not uniquely identify a year
and month if the week crosses a month boundary. To convert a year-week to
a date, you should also specify the weekday:
mysql>
SUBDATE(date,INTERVAL expr unit)
When invoked with the
for
[922]. For information on the
DATE_SUB()
[919].
DATE_ADD()
mysql>
SELECT DATE_SUB('2008-01-02', INTERVAL 31 DAY);
-> '2007-12-02'
mysql>
SELECT SUBDATE('2008-01-02', INTERVAL 31 DAY);
-> '2007-12-02'
The second form enables the use of an integer value for days. In such cases, it is interpreted as the
number of days to be subtracted from the date or datetime expression expr.
mysql>
SELECT SUBDATE('2008-01-02 12:00:00', 31);
-> '2007-12-02 12:00:00'
SUBTIME(expr1,expr2)
[928]
returns
SUBTIME()
is a time or datetime expression, and
expr1
mysql>
SELECT SUBTIME('2007-12-31 23:59:59.999999','1 1:1:1.000002');
-> '2007-12-30 22:58:58.999997'
mysql>
SELECT SUBTIME('01:00:00.999999', '02:00:00.999998');
-> '-00:59:59.999999'
[928]
SYSDATE()
Returns the current date and time as a value in
YYYYMMDDHHMMSS.uuuuuu
context.
As of MySQL 5.0.12,
the behavior for
NOW()
statement began to execute. (Within a stored function or trigger,
which the function or triggering statement began to execute.)
mysql>
SELECT NOW(), SLEEP(2), NOW();
+---------------------+----------+---------------------+
| NOW()
+---------------------+----------+---------------------+
| 2006-04-12 13:47:36 |
+---------------------+----------+---------------------+
mysql>
SELECT SYSDATE(), SLEEP(2), SYSDATE();
Date and Time Functions
Types". This means, for example, that "zero" dates or dates with part
"%X%V"
SELECT STR_TO_DATE('200442 Monday', '%X%V %W');
-> '2004-10-18'
form of the second argument,
INTERVAL
[928]
expressed as a value in the same format as expr1.
expr1
expr2
format, depending on whether the function is used in a string or numeric
[928]
returns the time at which it executes. This differs from
SYSDATE()
[926], which returns a constant time that indicates the time at which the
| SLEEP(2) | NOW()
0 | 2006-04-12 13:47:36 |
928
Section 11.1.5.1, "The DATE,
to convert a year-week string to a date
[928],
SUBDATE(expr,days)
SUBDATE()
argument, see the discussion for
INTERVAL unit
is a time expression.
expr2
'YYYY-MM-DD HH:MM:SS'
NOW()
|
[928]
[928]
is a synonym
or
[926]
returns the time at

Advertisement

Table of Contents
loading

This manual is also suitable for:

Mysql 5.0

Table of Contents