Php this month and next month

Source: Internet
Author: User
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 ")

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.