Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8908655
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T03:14:17+00:00 2026-06-15T03:14:17+00:00

Using select_date gives me back a params[:my_date] with year , month and day attributes.

  • 0

Using select_date gives me back a params[:my_date] with year, month and day attributes. How do get a Date object easily? I’m hoping for something like params[:my_date].to_date.

I’m happy to use date_select instead as well.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T03:14:18+00:00Added an answer on June 15, 2026 at 3:14 am

    Using date_select gives you 3 separate key/value pairs for the day, month, and year respectively. So you can pass them into Date.new as parameters to create a new Date object.

    An example date_select returned params for an Event model:

    "event"=>
     {"name"=>"Birthday",
      "date(1i)"=>"2012",
      "date(2i)"=>"11",
      "date(3i)"=>"28"},
    

    Then to create the new Date object:

    event = params[:event]
    date = Date.new event["date(1i)"].to_i, event["date(2i)"].to_i, event["date(3i)"].to_i
    

    You may instead decide to wrap this logic in a method:

    def flatten_date_array hash
      %w(1 2 3).map { |e| hash["date(#{e}i)"].to_i }
    end
    

    And then call it as date = Date.new *flatten_date_array params[:event]. But this is not logic that truly belongs in a controller, so you may decide to move it elsewhere. You could even extend this onto the Date class, and call it as date = Date.new_from_hash params[:event].

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using a self-join to get year-to-date totals. This works: SELECT tc.EmployeeID, tc.TimeCardNum,
I'm using a date select in a rails 3 form. <%=f.date_select :date %> I
Hi I'm using the wijmo popup calendar. I've managed to automatically select the date
can anyone tell me how to select data by date in MS.ACCESS database using
Can Django admin site select entries by a custom date range, i.e. using two
I am trying to select records that have the curent month using: SELECT *
I'm trying to perform the following query using MySQL: SELECT e.event, BINARY e.params as
I have a table that contains only Month and Year field both as int.
I'am using magento 1.7.2 and I want to add date attribute with time which
I'm using SQL Server 2008 and my fields have DATE type but in Visual

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.