Date and Time Functions
932
timestamp value.
FROM_UNIXTIME()
[923]
will map that value back to only one of the original
TIMESTAMP
values. Here is an example, using
TIMESTAMP
values in the
CET
time zone:
mysql>
SELECT UNIX_TIMESTAMP('2005-03-27 03:00:00');
+---------------------------------------+
| UNIX_TIMESTAMP('2005-03-27 03:00:00') |
+---------------------------------------+
| 1111885200 |
+---------------------------------------+
mysql>
SELECT UNIX_TIMESTAMP('2005-03-27 02:00:00');
+---------------------------------------+
| UNIX_TIMESTAMP('2005-03-27 02:00:00') |
+---------------------------------------+
| 1111885200 |
+---------------------------------------+
mysql>
SELECT FROM_UNIXTIME(1111885200);
+---------------------------+
| FROM_UNIXTIME(1111885200) |
+---------------------------+
| 2005-03-27 03:00:00 |
+---------------------------+
If you want to subtract
UNIX_TIMESTAMP()
[931]
columns, you might want to cast the result to
signed integers. See
Section 12.10, “Cast Functions and Operators”
.
•
UTC_DATE
[932]
,
UTC_DATE()
[932]
Returns the current UTC date as a value in
'YYYY-MM-DD'
or
YYYYMMDD
format, depending on
whether the function is used in a string or numeric context.
mysql>
SELECT UTC_DATE(), UTC_DATE() + 0;
-> '2003-08-14', 20030814
•
UTC_TIME
[932]
,
UTC_TIME()
[932]
Returns the current UTC time as a value in
'HH:MM:SS'
or
HHMMSS.uuuuuu
format, depending on
whether the function is used in a string or numeric context.
mysql>
SELECT UTC_TIME(), UTC_TIME() + 0;
-> '18:07:53', 180753.000000
•
UTC_TIMESTAMP
[932]
,
UTC_TIMESTAMP()
[932]
Returns the current UTC date and time as a value in
'YYYY-MM-DD HH:MM:SS'
or
YYYYMMDDHHMMSS.uuuuuu
format, depending on whether the function is used in a string or numeric
context.
mysql>
SELECT UTC_TIMESTAMP(), UTC_TIMESTAMP() + 0;
-> '2003-08-14 18:08:04', 20030814180804.000000
•
WEEK(date[,mode])
[932]
This function returns the week number for
date
. The two-argument form of
WEEK()
[932]
enables you to specify whether the week starts on Sunday or Monday and whether the return value
should be in the range from
0
to
53
or from
1
to
53
. If the
mode
argument is omitted, the value of
the
default_week_format
[446]
system variable is used. See
Section 5.1.4, “Server System
Variables”
.
The following table describes how the
mode
argument works.
Mode
First day of week Range
Week 1 is the first week …
0
Sunday
0-53
with a Sunday in this year
1
Monday
0-53
with more than 3 days this year
Summary of Contents for 5.0
Page 1: ...MySQL 5 0 Reference Manual ...
Page 18: ...xviii ...
Page 60: ...40 ...
Page 396: ...376 ...
Page 578: ...558 ...
Page 636: ...616 ...
Page 844: ...824 ...
Page 1234: ...1214 ...
Page 1427: ...MySQL Proxy Scripting 1407 ...
Page 1734: ...1714 ...
Page 1752: ...1732 ...
Page 1783: ...Configuring Connector ODBC 1763 ...
Page 1793: ...Connector ODBC Examples 1773 ...
Page 1839: ...Connector Net Installation 1819 2 You must choose the type of installation to perform ...
Page 2850: ...2830 ...
Page 2854: ...2834 ...
Page 2928: ...2908 ...
Page 3000: ...2980 ...
Page 3122: ...3102 ...
Page 3126: ...3106 ...
Page 3174: ...3154 ...
Page 3232: ...3212 ...