DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

John has posted 18 posts at DZone. View Full User Profile

Date_select Conversion

04.17.2008
| 5329 views |
  • submit to reddit
        function to convert a value from a date_select into a more sql-friendly value

<%=date_select(:date,'',:start_year => 1950,:include_blank => false, :default => { :year => '1970' })%>

def convert_date(obj) 
  return “#{obj[‘(1i)’]}-#{obj[‘(2i)’]}-#{obj[‘(3i)’]}” 
end