Home > Database > Mysql Tutorial > How to Retrieve the First Day of Corresponding Months in MySQL?

How to Retrieve the First Day of Corresponding Months in MySQL?

Patricia Arquette
Release: 2024-11-12 03:12:01
Original
294 people have browsed it

How to Retrieve the First Day of Corresponding Months in MySQL?

Finding the First Day of Corresponding Months in MySQL

This issue arises when needing to retrieve the first day of each month corresponding to a specific date in the current year. For instance, if the chosen date is '2010-06-15,' the query should display results from '2010-06-01' onward, not '2010-06-15.'

To compute the first day from the chosen date, the following SQL query can be used:

select CAST(DATE_FORMAT(NOW() ,'%Y-%m-01') as DATE);
Copy after login

The above is the detailed content of How to Retrieve the First Day of Corresponding Months in MySQL?. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template