Click here to Skip to main content
15,905,616 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
how to get last one month transaction in that database and how to use that query and how to bind in gridview
Posted

Try:
SQL
SELECT * FROM myTable WHERE transDate BETWEEN startDate AND endDate
 
Share this answer
 
SQL
SELECT * FROM mytable WHERE MONTH(transDate)=month AND YEAR(transDate)=presentYear

If that's a query you do often, I'd also store month and year in extra columns in that database (use a trigger to insert/update the values when a record gets inserted/updated).
 
Share this answer
 
hi
u can get from this query
SQL
SELECT * FROM tablename WHERE MONTH(DateColumnName)=MONTH(getdate())-1 AND YEAR(DateColumnName)=Year(getdate())
 
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