Let me see why a mysql Query always fails.

Source: Internet
Author: User
Let me see why a mysql Query always fails.
Select * from 'yun _ useitem' where date_format (from_UNIXTIME ('create _ time'), '% Y-% d') = date_format (now (), '% Y-% d ');


In this way, you can check the number of days.

Select * from 'yun _ useitem' where date_format (from_UNIXTIME ('create _ time'), '% Y-% M') = date_format (now (), '% Y-% M ');


That is, you can insert a month without data, and you don't know why there is data in the year of a single query. why is there no data in the month of M?


Reply to discussion (solution)

Are there any differences between your two commands?
Check the data of the current month.

Are there any differences between your two commands?
Check the data of the current month.



The first one I inserted is % Y-% d. This is the data of the day.

Second, I used % Y-% m to query no data for the current month.

Querying % Y also returns the data of the current year. the only data is % Y-% m-$ d and % Y-% m. In this case, no data is returned in the month.

Are there any differences between your two commands?
Check the data of the current month.



It turns out that I have adjusted the local time myself. because I only tested the data for the same month, it is natural that I have no data to query the data in the month. I am also drunk. the local machine was adjusted to the actual data in March. no language added in April

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.