Thread: C#-sql
View Single Post
Old 11-08-2006, 07:10 AM   #2 (permalink)
noobie
Forum Expert
 
Join Date: Jul 2005
Location: Istanbul/Turkey
Age: 27
Posts: 425
Default

if you are using Date object, you might get endDate by subtracting one day from next month.

however, what you are trying to achieve is too much simpler with something like this:

Quote:
select customerId, datepart(month,transDate), sum(transTotal) from Customers (nolock) c, Transactions (nolock) t where c.id=t.customerId and transDate >= ('01/01/'+convert(varchar,datepart(year,getdate()))) group by customerID, datepart(month,transDate)
the last AND statement might be unnecessary for your use and data..
__________________
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it."
noobie is offline   Reply With Quote