Click here to Skip to main content
15,867,686 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi Friends,

Mysql Query to display the records of all the days in a particular month using for loop means it has to start from starting day of the month and ends at the ending day of that particular month.If i passed the parameter as August it has to take the records from 2011-08-01,2011-08-02,..........2011-08-31 tables.How can i write a query for this.Can any one help me.
Posted

1 solution

It can be more simple:

SELECT * FROM TABLE WHERE MONTH(TABLE.DATEFIELD) = 8 and YEAR(TABLE.DATEFIELD) = 2011;
 
Share this answer
 
v3
Comments
komali Guntur 3-Aug-11 4:33am    
no sir its not working and i can pass any of the month whatever i want to the stored procedure as a paramater
Astolf 3-Aug-11 4:46am    
I just try it and it works.

If DATEFIELD is DATETIME you can select any month.

select * from table where month(datetimefield) = @parameter

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900