Home php How to compare a date from today in MySQL request?

How to compare a date from today in MySQL request?

Author

Date

Category

You need to compare the date from today or another specific date (for example -10 days) at the request itself, to make a sample. In the cell itself, the date is placed through the Time () :

$ date = date ("y-m-d", time ());
mysql_fetch_array (mysql_query ("SELECT * from` Table` Where date ('y-M-d', `date`) = '". $ date. "' '"));

Writes an error: mysql_fetch_array () EXPECTS PARAMETER 1 TO BE RESOURCE, BOOLEAN GIVEN


1, Authority 100%

Here it should help.


2, Authority 17%

was not strongly fond of these features mysql , but that’s what I decided to once for a long time:

mysql_query ("Delete from M_UONLINE WHERE (NOW () - UPDATED) & GT; = 300");

Table m_uonline In the updated field, the data was entered using Current_timeStamp and it worked, I needed to remove users who were not already celebrated 300 seconds (5 minutes), now () This is the internal function mysql generates the current date and time.

Hopefully come in handy.


3

1) Today:

mysql_fetch_array (mysql_query ("Select * from` Table` Where date ("". $ date. "') = Curdate ( ) "));

2) 10 days ago:

mysql_fetch_array (mysql_query ("select * from` Table` Where date ("". $ date. "') = Date_ADD ( Curdate (), Interval - 10 Day) "));

Programmers, Start Your Engines!

Why spend time searching for the correct question and then entering your answer when you can find it in a second? That's what CompuTicket is all about! Here you'll find thousands of questions and answers from hundreds of computer languages.

Recent questions