# Updated today - number of rows

**URL:** <https://www.ruby-forum.com/t/updated-today-number-of-rows/165283>\
**Category:** Rails\
**Created:** [April 11, 2009, 12:42pm UTC](https://www.ruby-forum.com/t/updated-today-number-of-rows/165283 "2009-04-11T12:42:10Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![giga](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/b9bd4f/32.png) [@giga](https://www.ruby-forum.com/u/giga)\
**Post date:** [April 11, 2009, 12:42pm UTC](https://www.ruby-forum.com/t/updated-today-number-of-rows/165283/1 "2009-04-11T12:42:10Z")

</div>

How can I get number of rows that was updated “today”?

Table: messages (id, title, message, updated\_at)

---

<div class="post-metadata">

**Author:** ![giga](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/b9bd4f/32.png) [@giga](https://www.ruby-forum.com/u/giga)\
**Post date:** [April 11, 2009, 1:17pm UTC](https://www.ruby-forum.com/t/updated-today-number-of-rows/165283/2 "2009-04-11T13:17:20Z")

</div>

On Apr 11, 11:42 am, Fresh M. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> How can I get number of rows that was updated “today”?
> 
> Table: messages (id, title, message, updated\_at)

Decide on your precise definition of today (since midnight, last 24  
hours etc.) and use ActiveRecord’s count method.

Fred

---

<div class="post-metadata">

**Author:** ![giga](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/b9bd4f/32.png) [@giga](https://www.ruby-forum.com/u/giga)\
**Post date:** [April 11, 2009, 1:25pm UTC](https://www.ruby-forum.com/t/updated-today-number-of-rows/165283/3 "2009-04-11T13:25:24Z")

</div>

Frederick C. wrote:

> On Apr 11, 11:42ï¿½am, Fresh M. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
> wrote:
> 
> > How can I get number of rows that was updated “today”?
> > 
> > Table: messages (id, title, message, updated\_at)
> 
> Decide on your precise definition of today (since midnight, last 24  
> hours etc.) and use ActiveRecord’s count method.
> 
> Fred

I think that last 24 hours is better

---

<div class="post-metadata">

**Author:** ![giga](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/b9bd4f/32.png) [@giga](https://www.ruby-forum.com/u/giga)\
**Post date:** [April 11, 2009, 5:33pm UTC](https://www.ruby-forum.com/t/updated-today-number-of-rows/165283/4 "2009-04-11T17:33:01Z")

</div>

named\_scope :recent, lambda { {:conditions =\> [‘updated\_at \> ?’,  
24.hours.ago]} }

On Apr 11, 7:25 pm, Fresh M. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
