andrew.ohnstad-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2007-Mar-30 03:03 UTC
Convert Number (1-12) into Month (Word)
Hi All, Checked the API and archives, but can''t seem to find anything. Before I roll my own I thought I would ask if this exists... I have a field in the DB that stores a month as a number from 1 to 12. I would like to convert that for use in a view as the word for the month. So 1 => January, 2=> February, and so on. Is there a function for this, or am I on my own? Thanks! --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
http://corelib.rubyonrails.org/classes/Date.html Date::MONTHNAMES andrew.ohnstad-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org wrote:> > > Hi All, > > Checked the API and archives, but can''t seem to find anything. Before > I roll my own I thought I would ask if this exists... > > I have a field in the DB that stores a month as a number from 1 to > 12. I would like to convert that for use in a view as the word for > the month. So 1 => January, 2=> February, and so on. > > Is there a function for this, or am I on my own? > > Thanks! > > > > > >-- View this message in context: http://www.nabble.com/Convert-Number-%281-12%29-into-Month-%28Word%29-tf3489990.html#a9746549 Sent from the RubyOnRails Users mailing list archive at Nabble.com. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
>> month = 1 >> Date::MONTHNAMES[month]=> ''January'' -christos On Mar 30, 5:03 am, "andrew.ohns...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org" <andrew.ohns...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi All, > > Checked the API and archives, but can''t seem to find anything. Before > I roll my own I thought I would ask if this exists... > > I have a field in the DB that stores a month as a number from 1 to > 12. I would like to convert that for use in a view as the word for > the month. So 1 => January, 2=> February, and so on. > > Is there a function for this, or am I on my own? > > Thanks!--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---