time BETWEEN DATE_ADD(curdate(),interval -day(curdate())+1 day) AND NOW()
时间: 2024-06-01 18:10:04 浏览: 160
This SQL query will select records that have a timestamp between the beginning of the current month (1st day) and the current date/time.
Explanation:
- `curdate()` returns the current date
- `day(curdate())` returns the day of the month for the current date
- `interval -day(curdate()) 1 day` subtracts the number of days in the current month from the current date, and then adds 1 day to get the 1st day of the current month
- `DATE_ADD(curdate(),interval -day(curdate()) 1 day)` returns the 1st day of the current month
- `NOW()` returns the current date/time
- `time BETWEEN DATE_ADD(curdate(),interval -day(curdate()) 1 day) AND NOW()` selects records that have a timestamp between the 1st day of the current month and the current date/time.
阅读全文