# Count of users between months

**URL:** <https://www.ruby-forum.com/t/count-of-users-between-months/144618>\
**Category:** Rails\
**Created:** [July 31, 2008, 3:14pm UTC](https://www.ruby-forum.com/t/count-of-users-between-months/144618 "2008-07-31T15:14:36Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![srinathbtech](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/7bcc69/32.png) [@srinathbtech](https://www.ruby-forum.com/u/srinathbtech)\
**Post date:** [July 31, 2008, 3:14pm UTC](https://www.ruby-forum.com/t/count-of-users-between-months/144618/1 "2008-07-31T15:14:36Z")

</div>

Hi,  
  
i was struggling how to get the count of users from jan 08 to july 08,  
i have a users\_trackers table with column names id, user\_id and  
updated\_at with different users  
and data from jan 08 till date.

i was using rails count method like this :

[code]  
@users\_count = UserTracker.count(:all, :conditions =\> [“updated\_at  
BETWEEN ? and ?”, 7.months.ago.to\_date, Date.today], :group =\>  
“DATE\_FORMAT(updated\_at, ‘%b %Y’)”, :order =\> :updated\_at)

getting output like this :  
[[“Feb 2008”, 1], [“Mar 2008”, 16], [“Apr 2008”, 35], [“May 2008”, 38],  
[“Jun 2008”, 19], [“Jul 2008”, 9]]  
in the above output i was getting the total sum of users existing i.e  
the users are repeated daily and getting the sum of those too  
i should get the output like this  
[[“Feb 2008”, 1], [“Mar 2008”, 3], [“Apr 2008”, 5], [“May 2008”, 5],  
[“Jun 2008”, 10], [“Jul 2008”, 15]][/code]  
should get only count of users that were there in that month if repeated  
too  
Say user\_id 1 repeated for 2008-07-06,2008-07-07, 2008-07-08 should get  
count = 1 and not 3

any help ??
