Php this month and last month can get the current day's time $ sqljrfw = & quot; selectttotalfromtotal_numberwhereto_days (tdate) = to_days (now () & quot ;; this tdate is a time field type 2012-08-16, so how can I make php 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?
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 ")
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