Urgent PHP: the createtime field type in the database is datetime. how can I query the data for a period of time based on this?

Source: Internet
Author: User
In an emergency, the createtime field type in the PHP database is datetime. how can we set the createtime field type in the data database to datetime based on the query time, which is year, month, day, hour, minute, second, how to convert it into a timestamp? There is a lot of data, a good conversion, but so much ?, Select & nbs urgent, PHP, the createtime field type in the database is datetime, how to query data within a period of time according to this
In the database, the createtime field is of the datetime type, which is year, month, day, hour, minute, and second. how can we convert it into a timestamp? There is a lot of data, a good conversion, but so much?
------ Solution --------------------
Select unix_timestamp ('2017-4-19 12:00:00 ');

------ Solution --------------------
Queries can be directly compared
For example, select * from table where createtime> = '2017-01-01 00:00:00 'and creattime <'2017-01-31 00:00:00 ';

This can be done if you want to batch display
Select *, unix_timestamp (createtime) as createtime from table;
------ Solution --------------------
Select * from table where createtime> = '2017-01-01 00:00:00 'and creattime <'2017-01-31 00:00:00 ';

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.