Re: How can I totalize by month, by year?
- To: mathgroup at smc.vnet.net
- Subject: [mg111902] Re: How can I totalize by month, by year?
- From: E. Pérez Herrero <enriqueperezherrero at gmail.com>
- Date: Wed, 18 Aug 2010 07:05:25 -0400 (EDT)
- References: <201006301204.IAA27569@smc.vnet.net> <i4d6av$6r3$1@smc.vnet.net>
data = {{{{2010, 8, 3, 0, 0, 0.}, 65.}, {{2010, 8, 3, 0, 0, 0.}, -72.}, {{2010, 8, 3, 0, 0, 0.}, 45.}, {{2010, 8, 2, 0, 0, 0.}, 67.}, {{2010, 8, 2, 0, 0, 0.}, 83.}, {{2010, 8, 2, 0, 0, 0.}, -42.}, {{2010, 7, 30, 0, 0, 0.}, -32.}, {{2010, 7, 30, 0, 0, 0.}, 48.}, {{2010, 7, 30, 0, 0, 0.}, 12.}, {{2010, 7, 30, 0, 0, 0.}, 34.}, {{2010, 7, 29, 0, 0, 0.}, -52.}, {{2010, 7, 29, 0, 0, 0.}, 78.}, {{2010, 7, 29, 0, 0, 0.}, -26.}, {{2010, 7, 28, 0, 0, 0.}, 45.}, {{2010, 7, 28, 0, 0, 0.}, -23.}, {{2010, 7, 28, 0, 0, 0.}, -32.}, {{2010, 7, 28, 0, 0, 0.}, 74.}, {{2010, 7, 27, 0, 0, 0.}, 53.}, {{2010, 7, 27, 0, 0, 0.}, 58.}, {{2010, 7, 27, 0, 0, 0.}, 25.}}}; TotalizePerDate[data_, day_, month_, year_] := Plus @@ Select[ Flatten[data, 1], (#[[1]][[1]] == year) && (#[[1]][[2]] == month) && (#[[1]][[3]] == day) &][[All, 2]] Example with your data named with the original and unexpected name of "data": TotalizePerDate[data, 3, 8, 2010]