MySQL Database time query

Source: Internet
Author: User

1, query the current time of month and day seconds

Mysql> Select Now (); +---------------------+| Now ()               2018-03-19 23:12:52 |+---------------------+

2. Check the time of three hours before the current time

Subdate (now (), Interval 3   hour); +--------------------------------+| Subdate (now (), Interval 3 hour) |+--------------------------------+| 2018-03-19 20:13:11            |+--------------------------------+

3. Check the time of three days before the current time

Mysql> Select Subdate (now (), Interval 3 day  ); +-------------------------------+| Subdate (now (), Interval 3 day) |+-------------------------------+| 2018-03-16 23:13:23           |+-------------------------------+

4, check the new current time three minutes before the point of time

Mysql> Select Subdate (now (), Interval 3  minute); +----------------------------------+| Subdate (now (), Interval 3 minute) |+----------------------------------+| 2018-03-19 23:10:32              |+----------------------------------+

5, query the current time of the second

Mysql>current_time (); +----------------+| Current_time () |+----------------+| 23:14:09       |+----------------+

6, query the current time of month and day seconds

Mysql>current_date (); +----------------+| Current_date () |+----------------+| 2018-03-19     |+----------------+

MySQL Database time query

Related Article

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.