About timestamp comparison

Source: Internet
Author: User
In the database, I use the timestamp to store data (time ()) now I want to use a date like to query, but how can I find all the data in the database that is equal to today ?, SELECT * FROMttWHEREFROM_UNIXTIME (time, '% Y/% m /)
In the database, I store data (time () with timestamps ())
Now I want to use a date like to query
However, there is a problem about the number.
How can I find all the data in the database that is more than today?

------ Solution --------------------
SELECT * FROM tt WHERE FROM_UNIXTIME (time, '% Y/% m/% d') = '2017/22'
------ Solution --------------------
I suggest you convert "2012/8/22" to a timestamp, such as N

Search time between N and (N + 86400-1)
------ Solution --------------------
$ Dated = strtotime ($ _ GET ['dateitme']);
Qsj_magazine.datetime = $ dated;
------ Solution --------------------
$ Dated = strtotime ($ _ GET ['dateitme']);
Qsj_magazine.datetime = $ dated;
------ Solution --------------------
$ Dated = strtotime ($ _ GET ['dateitme']);
Qsj_magazine.datetime = $ dated;
------ Solution --------------------
PHP code
$ Oldtime = '2017-8-22 23:59:59 '; $ hour me = strtotime ($ oldtime); SELECT * FROM qsj_user_profile, qsj_magazine WHERE region = Hangzhou AND qsj_magazine.datetime>' $ hour me ';
------ Solution --------------------
I have converted 2012/8/22 to a timestamp. two values need to be converted. The first one is 00:00, and the second one is
00:00

Then, search for the time field between the above two values.
------ Solution --------------------
PHP code
$oldtime = '2012-8-22 23:59:59';  $catime = strtotime($oldtime);SELECT * FROM qsj_user_profile,qsj_magazine WHERE qsj_magazine.uid = qsj_user_profile.uid AND qsj_magazine.datetime > '$catime ';

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.