Click here to Skip to main content
15,888,072 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a datatable in which there are 2 date column and 2 amount column
I want to sum the amountpaid for 2013 and 2014 seperately
Note:Date is in mmmddyyyy format

CSS
inputmonth     stamp2datetime  amountpaid  stampdutypaid

2/1/2014 0:00   2/21/2014 17:58    550     100
2/1/2013 0:00   2/26/2013 18:29    550     100
2/1/2014 0:00   2/5/2014 11:05     100     360
2/1/2014 0:00   2/14/2014 12:57    5650    28250
2/1/2014 0:00   2/14/2014 13:15    100     300
2/1/2014 0:00   2/20/2014 12:39    770     3950
2/1/2014 0:00   2/18/2014 18:05    1240    6175
2/1/2013 0:00   2/20/2013 12:19    120     600
2/1/2013 0:00   2/20/2013 15:34    100     200
2/1/2013 0:00   2/20/2013 17:51    100     100
2/1/2013 0:00   2/20/2013 17:23    100     250
2/1/2014 0:00   2/21/2014 17:34    790     3950
2/1/2014 0:00   2/28/2014 18:25    2350    7035
2/1/2014 0:00   2/26/2014 16:01    100     15
2/1/2014 0:00   2/28/2014 12:37    4330    12990


sumObject = table.Compute("Sum(amountpaid)", "inputmonth= 2013");
I want o filter the datatable on date columns where inputmonth and stamp2datetime is 2013.
Posted

1 solution

try this one it may help u


SELECT DATEADD(dd, 0, DATEDIFF(dd, 0, p_date)) [date],
SUM(p_amount) [sum]
FROM Payments
WHERE DATEADD(dd, 0, DATEDIFF(dd, 0, p_date)) BETWEEN '20130701' AND '20130731'
GROUP BY DATEADD(dd, 0, DATEDIFF(dd, 0, p_date))
 
Share this answer
 
Comments
EliteBrain 19-Mar-14 8:20am    
HI VSRIKANTH THANKS FOR YOUR PROMPT REPLY

But i have data in ado.net datatable not database table.
So i want to sum using compute method of datatable(ado.net).

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