Home >Database >Mysql Tutorial >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);
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!