# Find\_by\_sql timestamp parameter

**URL:** <https://www.ruby-forum.com/t/find-by-sql-timestamp-parameter/189142>\
**Category:** Rails\
**Created:** [May 25, 2010, 10:29am UTC](https://www.ruby-forum.com/t/find-by-sql-timestamp-parameter/189142 "2010-05-25T10:29:03Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![stanislavua](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/d07c76/32.png) [@stanislavua](https://www.ruby-forum.com/u/stanislavua)\
**Post date:** [May 25, 2010, 10:29am UTC](https://www.ruby-forum.com/t/find-by-sql-timestamp-parameter/189142/1 "2010-05-25T10:29:03Z")

</div>

Hi  
In controller I have this query:

@price\_stat = Price.find\_by\_sql(“select id, cost, tour\_id,  
unix\_timestamp(created\_at) from prices”)

when I try to display result’s created\_at column I don’t have any  
results:

\<% @price\_stat.each do |p| %\>

\<%= p.created\_at %\>

\<% end %\>

result is empty

But if I try without unix\_timestamp. ie:

@price\_stat = Price.find\_by\_sql(“select id, cost, tour\_id, created\_at  
from prices”)

It works fine. ( \<%= p.created\_at %\> )

How I can get value of created\_at column when using unix\_timestamp?

Thanks in advance

---

<div class="post-metadata">

**Author:** ![stanislavua](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/d07c76/32.png) [@stanislavua](https://www.ruby-forum.com/u/stanislavua)\
**Post date:** [May 25, 2010, 12:35pm UTC](https://www.ruby-forum.com/t/find-by-sql-timestamp-parameter/189142/2 "2010-05-25T12:35:13Z")

</div>

On May 25, 9:29 am, Stanislav O. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> \<%= p.created\_at %\>
> 
> \<% end %\>

> result is empty

Because created\_at is no longer in the select list - some column with  
a different name is there instead. You should probably to something  
like unix\_timestamp(created\_at) as unix\_created\_at in your select  
clause (and then p.unix\_created\_at should be that value)

Fred
