我们有一个后端表,用于存储事务的详细信息,包括自epoch以来的秒数。我正在创建一个UI,我从中收集日期以显示日期之间发生的事务计数。Python计算给定日期范围内的记录数
假设日期范围从2012年7月1日至2012年7月30日,我无法建立一个逻辑来增加一个计数器以记录在该时间段内发生的记录。我应该只打一次数据库,因为每天的打击都会导致糟糕的表现。
我被困在一个逻辑:
Convert 07/01/2012 & 07/30/2012 to seconds since epoch.
Get the records for start date - end date [as converted to seconds since epoch]
For each record get the month/date
-- now how will we add counters for each date in between 07/01/2012 - 07/30/2012
分配每个日期范围在字典中每次找到一个键,+1的值该范围内的项目? – cdarke 2012-07-27 09:31:03
@cdarke:你可以在MySQL中完成它.. – 2012-07-27 09:32:23
@Prakash:对不起,我不知道(看起来像你有答案无论如何) – cdarke 2012-07-27 09:47:52