13
任何人都可以请建议查询从数据库中获取当前日期吗?Mysql查询从数据库中获取当前日期?
任何人都可以请建议查询从数据库中获取当前日期吗?Mysql查询从数据库中获取当前日期?
The fine manual有这样说的NOW
功能:
mysql> SELECT NOW();
-> '2007-12-15 23:50:26'
如果你只想要日期,然后使用CURDATE
。 The fine manual有这样说的CURDATE
功能:
mysql> SELECT CURDATE();
-> '2008-06-13'
的MySQL日期函数 下表列出了最重要的内建日期函数在MySQL:
Function Description
NOW() Returns the current date and time
CURDATE() Returns the current date
CURTIME() Returns the current time
DATE() Extracts the date part of a date or date/time expression
EXTRACT() Returns a single part of a date/time
DATE_ADD() Adds a specified time interval to a date
DATE_SUB() Subtracts a specified time interval from a date
DATEDIFF() Returns the number of days between two dates
DATE_FORMAT() Displays date/time data in different formats
可能是使用全
SQL日期数据类型 MySQL附带以下数据类型用于在数据库中存储日期或日期/时间值:
DATE - format YYYY-MM-DD
DATETIME - format: YYYY-MM-DD HH:MM:SS
TIMESTAMP - format: YYYY-MM-DD HH:MM:SS
YEAR - format YYYY or YY
实例查询:
SELECT NOW();
Will Return '2007-12-15 23:50:26'
'SELECT 'www.google.com' AS answer' –
http://dev.mysql.com/doc/refman/5.7/en/date-and- time-functions.html –
http://www.w3schools.com/sql/func_now.asp –