Php returns the current day's time $ sqljrfw & quot; selectttotalfromtotal_numberwhereto_days (tdate) to_days (now () & quot; from this month and last month ;; this tdate is a time field of the type 2012-08-16, so how can I get all the data for this month? There are also the number of php files in the last month of August this month, last month
In this way, we can get the current day's time.
$ Sqljrfw = "select ttotal from total_number where to_days (tdate) = to_days (now ())";
This tdate is a time field of the type 2012-08-16, so how can I get all the data for this month? What is the data of the last month of August?
------ Solution --------------------
Date_format (tdate, '% Y-% M') = 'Year-month'
The value you need for the year and month
------ Solution --------------------
Sorry, wrong. I forgot to consider the year. Change it to the following:
Month: select ttotal from total_number where date_format (tdate, "% Y-% m") = date_format (now (), "% Y-% m ")
Last month: select ttotal from total_number where date_format (tdate, "% Y-% m") = date_format (date_sub (now (), interval 1 month ), "% Y-% m ")