# Column types and date formatting

**URL:** <https://www.ruby-forum.com/t/column-types-and-date-formatting/112883>\
**Category:** Rails\
**Created:** [August 24, 2007, 3:38am UTC](https://www.ruby-forum.com/t/column-types-and-date-formatting/112883 "2007-08-24T03:38:30Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![arigold](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/77aa72/32.png) [@arigold](https://www.ruby-forum.com/u/arigold)\
**Post date:** [August 24, 2007, 3:38am UTC](https://www.ruby-forum.com/t/column-types-and-date-formatting/112883/1 "2007-08-24T03:38:30Z")

</div>

hi everyone,

working on my education tool here (im a teacher) and am having trouble  
getting my times to format right. im using the scaffold code and  
thought this would work:

```
<td>
  <% if lesson.send(column.name).type == "Time" %>
  <%=h lesson.send(column.name).strftime("%I:%M") %>
  <% else %>
  <%= h lesson.send(column.name) %>
  <% end %>
</td>

```

but that whole .time == “Time” thing doesnt seem to work. is there a  
better way to do this? or, heck, one that works? ive looked all over  
but im trying to get this running before the kids get there sept 4th  
so im looking for some ninjas who know whats kickin…

thanks a heck of a bunch! ~ari (gold, but i really teach. im no  
hollywood agent.)

---

<div class="post-metadata">

**Author:** ![arigold](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/77aa72/32.png) [@arigold](https://www.ruby-forum.com/u/arigold)\
**Post date:** [August 24, 2007, 4:05pm UTC](https://www.ruby-forum.com/t/column-types-and-date-formatting/112883/2 "2007-08-24T16:05:00Z")

</div>

well, lookee here. im going to answer my own questions (kind of), for  
the sake of those (one person?) who come across it.

as ive been working with the excellent book “agile web development on  
rails v2”, my answer is from there, chapter 6.4 (p. 76ish).

i got that snippet of code from the scaffolding generator. the  
generator makes things generic, hence the  
h lesson.send(column.name)  
but once you’re working with specifics, you dont need to use the  
generics (although there might be a way to do things with the  
generics… cant figure it out). so you can specify column names and,  
with the specified column name, do things with strftime which need  
date fields…

```
 lesson.start_time.strftime("%I:%M")

```

thats pretty much it. naturally, each column needs to be specified -  
instead of that lesson.send(column.name) thing up there… ~ari
