i take the current date and find the last year in ruby with *1.year.ago.
so i got 2 years 2010-12-14 to 2011-12-14. My question is how to get all
the months between these two dates in ruby in rails...? also these dates
will change depend on the current system date...*
*
*
*thank you*
*vishnu*

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/yVFmqtipxtgJ.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

Search Discussions

  • Michael Pavling at Dec 14, 2011 at 9:40 am

    On 14 December 2011 09:37, amvis wrote:
    i take the current date and  find the last year in ruby with 1.year.ago. so
    i got 2 years  2010-12-14 to 2011-12-14. My question is how to get all the
    months between these two dates in ruby in rails...? also these dates will
    change depend on the current system date...
    What have you tried? Where have you looked for solutions? What
    problems have you encountered?

    --
    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@googlegroups.com.
    To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
  • Amvis at Dec 14, 2011 at 7:45 pm
    @lastyear = 1.year.ago. it will give the last year. but it will shows date
    with time.

    2010-12-14 19:44:28 UTC

    How to avoid that time...? i have to get only the date 2010-12-14...

    Thank you
    vishnu

    --
    You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
    To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/mPrqf1kwynQJ.
    To post to this group, send email to rubyonrails-talk@googlegroups.com.
    To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
  • Colin Law at Dec 14, 2011 at 8:33 pm

    On 14 December 2011 19:45, amvis wrote:
    @lastyear = 1.year.ago. it will give the last year. but it will  shows date
    with time.

    2010-12-14 19:44:28 UTC

    How to avoid that time...? i have to get only the date 2010-12-14...
    Have a look at the documentation for the Time class, there are many
    methods that you can use.
    When you say you want to "get" the date do you mean you want it in a
    variable or you want to convert it to a string for display?
    If you want it in a variable then you can make a new Time object using
    day, month, year from original one (leaving hours, mins, seconds as
    zero so it represents the start of the day). If you want it as a
    string then look at strftime.

    Colin

    --
    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@googlegroups.com.
    To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouprubyonrails-talk @
categoriesrubyonrails
postedDec 14, '11 at 9:38a
activeDec 14, '11 at 8:33p
posts4
users3
websiterubyonrails.org
irc#RubyOnRails

People

Translate

site design / logo © 2022 Grokbase