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."
|