Date and Time functionsThis chapter discusses some functions that can be used to manipulate time values. See section 11.3, "Date and Time type" for valid formats for each time and date type with a range and a specified value.
The following example
[Go to] obtain the first day of the current week, month, and quarter in MySQL on the last day. The last day of the current week, month, and quarter in MySQL is taken from: hideto. javaeye. comblog255816 the first day of the current week:
MySQL
For the value range of each type and the valid format of the specified date value, see 7.3.6 Date and Time type.
Here is an example of using the date function. The following query Selects all records. The value of date_col is within the last 3
MySQL date data type and time type usage summary MySQL date type: Date format, storage space occupied, date range comparison.
Date type storage space date format date range
-----------------------------------------------------------------------------
Mysql> SELECT something from Tbl_name
WHERE To_days (now ()) –to_days (date_col)
DayOfWeek (date)
Returns the week index of date (1 = Sunday, 2 = Monday, ...). 7 = Saturday). Index values are compliant with ODBC standards.
mysql> SELECT DayOfWeek ('
The following query selects the records for all date_col values within the last 30 days.
Mysql> SELECT something from Tbl_name
WHERE To_days (now ())-To_days (Date_col) DayOfWeek (date)
Returns the week index of date (1 = Sunday, 2 = Monday, ...). 7
MySQL date type: Date Format, storage space occupied, and date range comparison.Date type storage space date format date range-----------------------------------------------------------------------------------Datetime 8 bytes YYYY-MM-DD hh: mm: SS 10
MySQL obtains the current date and time stamp function bitsCN.com
MySQL returns the current date, time, and timestamp.
1.1 obtain the current date + time (date + time) function: now ()
Mysql> select now ();
+ ------- +
| Now () |
+ ------- +
| 22:2
Oracle and Mysql time formatting 1. Oracle formatting time: Oracle obtains the current date and Date Format
Get system date: SYSDATE () format Date: TO_CHAR (SYSDATE (), 'yy/MM/DD HH24: MI: SS) or TO_DATE (SYSDATE (), 'yy/MM/DD HH24: MI: SS) format
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.