Locating the first day of the month in SQL
Here you'll find a simple way to locate the first day of the month in SQL
I needed to select records for this month so far from the database, which required getting the first day of the current month. After a while, I worked out the following code. To get the prior 12 months, add "- 12 months" after the "+ 1 day" part.
select * from file
where indate >=
date(curdate() - day(curdate()) days + 1 day)
==================================
MORE INFORMATION ON THIS TOPIC
==================================
The Best Web Links: tips, tutorials and more.
Visit the ITKnowledge Exchange and get answers to your developing questions fast.
Ask the Experts yourself: Our application development gurus are waiting to answer your programming questions.
Start the conversation
0 comments