I cant ponder how to do that. We have clients who use our transportation service. I constructed sql server table with name Debt its relationed with transportation ID and cl开发者_如何转开发ient ID. Clients always pay money at end of month. How can i do with c# or sql server that count all entries from month begining to end of month ? Sorry for my bad English. I hope that my question is understandable. Please Advice me something...
Substitute your date in place of myDateColumnName
and it will give you all the count for the current month -
select count(*) from debt
where Month(myDateColumnName) = Month(getdate())
If you already know the month number, for eg:- 10, then -
select count(*) from debt
where Month(myDateColumnName) = 10
Any further conditions to satisfy your criteria, you can add to the given query.
SELECT * FROM MYTABLE WHERE PayDate >= '2010-11-01T00:00:00'
Your sql would be something similar to:
select count(*)
from Debt
where startdate > '01/01/2010' and enddate < '31/01/2010'
Obviously substitute those dates above. You might want to play around with => and <= depending on exactly what date range you're looking for.
This will return a single integer which is the count.
In order to get it into your app you'll need to take a look at the System.Data.SqlClient namespace
精彩评论