Ask A Question


You’re not receiving notifications from this thread.

How do I display just the year in a sect date?

Rob Thomas asked in Rails

Good day Rails Devs,

What's the proper way to dsiplay just the year in:

<%= form.date_select :year %>

There are a couple options called discard_day and discard_month that you could set to true to hide them and only display the year. All the options are listed here:


Got it, thanks Chris!

<%= form.date_select :year, :discard_day   => true, :discard_month => true, class: 'form-control' %>
Join the discussion
Create an account Log in

Want to stay up-to-date with Ruby on Rails?

Join 76,990+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.

    Screencast tutorials to help you learn Ruby on Rails, Javascript, Hotwire, Turbo, Stimulus.js, PostgreSQL, MySQL, Ubuntu, and more. Icons by Icons8

    © 2023 GoRails, LLC. All rights reserved.