Mysql date comparison statement

Source: Internet
Author: User


Mysql date comparison statement select * from student where '2017-02-27 00:00:00 '<created_date and '2017-02-29 00:00:00'> created_date select * from student where UNIX_TIMESTAMP ('2017-2012- 02-27 00:00:00 ') <UNIX_TIMESTAMP (created_date) and UNIX_TIMESTAMP ('2017-02-29 00:00:00 ')> UNIX_TIMESTAMP (created_date); www.2cto.com SELECT * FROM student WHERE (UNIX_TIMESTAMP (created_date) -UNIX_TIMESTAMP ('2017-02-26 00:00:00 ')) > = 0 AND (UNIX_TIMESTAMP (created_date)-UNIX_TIMESTAMP ('2017-02-29 00:00:00 ') <= 0 The unix_timestamp function for MySql time comparison can accept a parameter, you can also choose not to use parameters. The return value is an unsigned integer. If the parameter is not used, it returns the number of seconds that have elapsed since 00:00:00, January 1, January 1, 1970. If the parameter is used, the parameter type is time or time string representation, it is the number of seconds that have elapsed since 00:00:00 to the specified time.

With this function, you can naturally convert the time comparison into a comparison of unsigned integers. For example, determine whether a time is in a single interval unix_timestamp (time) between unix_timestamp ('start') and unix_timestamp ('end ')

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.