Date and Time Functions
915
Returns the number
X
, truncated to
D
decimal places. If
D
is
0
, the result has no decimal point or
fractional part.
D
can be negative to cause
D
digits left of the decimal point of the value
X
to become
zero.
mysql>
SELECT TRUNCATE(1.223,1);
-> 1.2
mysql>
SELECT TRUNCATE(1.999,1);
-> 1.9
mysql>
SELECT TRUNCATE(1.999,0);
-> 1
mysql>
SELECT TRUNCATE(-1.999,1);
-> -1.9
mysql>
SELECT TRUNCATE(122,-2);
-> 100
mysql>
SELECT TRUNCATE(10.28*100,0);
-> 1028
All numbers are rounded toward zero.
12.7. Date and Time Functions
This section describes the functions that can be used to manipulate temporal values. See
Section 11.1.5, “Date and Time Types”
, for a description of the range of values each date and time type
has and the valid formats in which values may be specified.
Table 12.13. Date/Time Functions
Name
Description
ADDDATE()
[917]
Add time values (intervals) to a date value
ADDTIME()
[917]
Add time
CONVERT_TZ()
[918]
Convert from one timezone to another
CURDATE()
[918]
Return the current date
CURRENT_DATE()
,
CURRENT_DATE
[918]
Synonyms for CURDATE()
CURRENT_TIME()
,
CURRENT_TIME
[918]
Synonyms for CURTIME()
CURRENT_TIMESTAMP()
,
CURRENT_TIMESTAMP
[918]
Synonyms for NOW()
CURTIME()
[918]
Return the current time
DATE_ADD()
[919]
Add time values (intervals) to a date value
DATE_FORMAT()
[921]
Format date as specified
DATE_SUB()
[922]
Subtract a time value (interval) from a date
DATE()
[918]
Extract the date part of a date or datetime expression
DATEDIFF()
[919]
Subtract two dates
DAY()
[922]
Synonym for DAYOFMONTH()
DAYNAME()
[923]
Return the name of the weekday
DAYOFMONTH()
[923]
Return the day of the month (0-31)
DAYOFWEEK()
[923]
Return the weekday index of the argument
DAYOFYEAR()
[923]
Return the day of the year (1-366)
EXTRACT()
[923]
Extract part of a date
FROM_DAYS()
[923]
Convert a day number to a date
FROM_UNIXTIME()
[923]
Format UNIX timestamp as a date
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 ...