How does php query data within a certain time range of the current day?

Source: Internet
Author: User
How does php query data within a certain time range of the current day? To connect to the mysql database using php, you need to query data within a certain period of time (or several moments) every day. for example, you need to query whether data is received in the database between-on the current day, what should I do?


Reply to discussion (solution)

Select... where time between start and end

Select * from table where addtime> = '? Start ?? And addtime <= '? ?? ';

I only checked the data of the day. The upstairs writing method found all the data in the database during this time period.

Select... where time between start and end


How to write data on the day of "time?
The start time and end time are only hours, minutes, and seconds. how can this problem be solved?
I want to query the data within the time range of each day, instead of the data of a specific day.

Select * from table where addtime> = '? Start ?? And addtime <= '? ?? ';


I only query the data of the current day. how do I write the data of the current day?
The start time and end time are only hours, minutes, and seconds. how can this problem be solved?
I want to query the data within the time range of each day, instead of the data of a specific day.

DATE_FORMAT () is the time format you want to query. However, the efficiency will be low.


Select * from table where addtime> = '? Start ?? And addtime <= '? ?? ';


I only query the data of the current day. how do I write the data of the current day?
The start time and end time are only hours, minutes, and seconds. how can this problem be solved?
I want to query the data within the time range of each day, instead of the data of a specific day.



$ Starttime = '17: 25: 00 ';
$ Endtime = '17: 35: 00 ';

$ SQL = "select * from table where addtime> = '". date ('Y-m-D '). ''. $ starttime. "'and addtime <= '". date ('Y-m-D '). ''. $ endtime. "'";

The original landlord's date and time are stored in two fields, then you have to use date + time to form a new value, with date + time> = '? Start date ?? 'And date + time <= '? Start date ?? '



Select * from table where addtime> = '? Start ?? And addtime <= '? ?? ';


I only query the data of the current day. how do I write the data of the current day?
The start time and end time are only hours, minutes, and seconds. how can this problem be solved?
I want to query the data within the time range of each day, instead of the data of a specific day.



$ Starttime = '17: 25: 00 ';
$ Endtime = '17: 35: 00 ';

$ SQL = "select * from table where addtime> = '". date ('Y-m-D '). ''. $ starttime. "'and addtime <= '". date ('Y-m-D '). ''. $ endtime. "'";


I am very grateful to the moderator. I am already OK. which books or Baidu can I find for this knowledge? I just started to learn about it. I only talk about basic queries for the books and videos I am looking, insert and delete operations. no further details are available.

#3 I only query the data of the day. The upstairs writing method found all the data in the database during this time period.
#4 I want to query the data within the time range of each day, instead of the data of a specific day.

So what are you looking?




Select * from table where addtime> = '? Start ?? And addtime <= '? ?? ';


I only query the data of the current day. how do I write the data of the current day?
The start time and end time are only hours, minutes, and seconds. how can this problem be solved?
I want to query the data within the time range of each day, instead of the data of a specific day.



$ Starttime = '17: 25: 00 ';
$ Endtime = '17: 35: 00 ';

$ SQL = "select * from table where addtime> = '". date ('Y-m-D '). ''. $ starttime. "'and addtime <= '". date ('Y-m-D '). ''. $ endtime. "'";


I am very grateful to the moderator. I am already OK. which books or Baidu can I find for this knowledge? I just started to learn about it. I only talk about basic queries for the books and videos I am looking, insert and delete operations. no further details are available.



Look at some? SOURCE system? ?.
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.