Click here to Skip to main content
15,903,203 members
Please Sign up or sign in to vote.
1.41/5 (5 votes)
Dear friends


I have data base having data for 12 months now i want to pick the data only for one month say i want report of june 2013 what is the query for that user will select month and year
Posted
Updated 28-Mar-19 22:10pm
v2

Select * from student where month (12_march_2010)=@month
 
Share this answer
 
Comments
CHill60 26-Mar-19 9:06am    
You have a column called [12_march-2010] - what on earth would you store in that?
Example:
SQL
SELECT *
FROM TableName
WHERE MONTH(DateColumn)=@month AND YEAR(DateColumn)=@year
 
Share this answer
 
Comments
CHill60 29-Mar-19 6:52am    
The beauty of numbskulls copying earlier solutions is that I get to notice and upvote the nice, simple, correct solution. 5'd
Maciej Los 29-Mar-19 7:25am    
Thank you, Caroline.
Did you notice that i've answered this question almost 6 years ago?
CHill60 29-Mar-19 8:48am    
Yes - I know! See Solution 2 and 3 :sigh:
Maciej Los 29-Mar-19 9:00am    
Seems, i'm blind man. ;)
CHill60 29-Mar-19 9:59am    
LOL! The members that posted those other solutions are the ones with the eye problems my friend :)

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