# Show text or image, based on data value

**URL:** <https://www.ruby-forum.com/t/show-text-or-image-based-on-data-value/164569>\
**Category:** Rails\
**Created:** [April 2, 2009, 5:39pm UTC](https://www.ruby-forum.com/t/show-text-or-image-based-on-data-value/164569 "2009-04-02T17:39:06Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![remco](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/9d8465/32.png) [@remco](https://www.ruby-forum.com/u/remco)\
**Post date:** [April 2, 2009, 5:39pm UTC](https://www.ruby-forum.com/t/show-text-or-image-based-on-data-value/164569/1 "2009-04-02T17:39:06Z")

</div>

Hi,

I have a table sales with the columns, title, short\_description,  
long\_description, start\_date, end\_date. The columns start\_date end  
end\_date has both a date value.

My sales record are show on a index-page, with the start\_date and  
end\_date published.

I want on the index-page a “timer” based on end\_date. By example today  
it is 2 april and a sales availability end\_date is 4 april, i want to  
show to the consumer “You only have 2 days left” or a image(2.gif) with  
text in the same context…

I am newbie…someone suggestions/links?

Grtz…remco

---

<div class="post-metadata">

**Author:** ![remco](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/9d8465/32.png) [@remco](https://www.ruby-forum.com/u/remco)\
**Post date:** [April 3, 2009, 5:23pm UTC](https://www.ruby-forum.com/t/show-text-or-image-based-on-data-value/164569/2 "2009-04-03T17:23:11Z")

</div>

Use date comparison functions (DATEDIFF, CURRENT\_DATE) in your  
database query.

[http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html](http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html)

On Apr 2, 11:39 am, Remco S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
