Click here to Skip to main content
15,887,477 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
hello everybody
how to get month wise and year wise report from database
i have idea on day wise
that code is
select * from tbl1 where slipdate='01/24/2011'

anybody give me some examples....
Posted

Hello Dear,

You can get the data year wise and month wise also.

To get the year wise data you have to get the year part and month part of the slipdate and then set your desired year or month to filter the record.

To get the month and the year of the slipdate you can use the below code

select * from tbl1 where convert(bigint, datepart(yy,slipdate))=2011

below code is to get month wise report.
select * from tbl1 where convert(bigint, datepart(mm,slipdate))=1
here january is 1
Feb=2 and so on.
 
Share this answer
 
Comments
selva_1990 15-Dec-12 11:33am    
Is it possible to get data week wise too, if so give one example like above
Look at the SQL DATEPART[^] function - it can return you the month, or year section of a date in the database. Then all you have to do is check them against the reporting date range you are interested in.
 
Share this answer
 

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