Mindtonic

Thoughts on Music and Application Development
  • Home
  • About

Archive

Archive for the ‘Ruby’ Category

Calculating The Number Of Months Between Two Dates In Ruby

September 17th, 2009 mindtonic 1 comment

My research led me here: http://www.francisfish.com/getting_the_number_of_months_between_two_dates_in_rubyrails.htm

This is the method I came up with:

def self.months_between( startdate=Time.now, enddate=Time.now )
  startdate ||= Time.now
  enddate ||= Time.now

  (enddate.month - startdate.month) + 12 * (enddate.year - startdate.year)
end
Categories: Ruby Tags:
RSS

Random Posts

  • Indexing Ultrasphinx with Rufus Scheduler
  • Rails Javascript and CSS Compression
  • Working With Server Processes
  • Treasures Recommended by Emphasized Insanity
  • Beginning the GIT transition

Tag Cloud

apache BackgrounDRb css delayed_job factory_girl feednormalizer gem git javascript mysql Paperclip pear PHP phpunit prototype rails ruby Rufus shabda shoulda simpletest sphinx testing ultrasphinx Unix webrat

Categories

  • Development
  • Uncategorized

Blogroll

  • Development Blog
  • Documentation
  • Plugins
  • Suggest Ideas
  • Support Forum
  • Themes
  • WordPress Planet

Archives

  • March 2010
  • January 2010
  • December 2009
  • October 2009
  • September 2009
  • August 2009
  • July 2009
  • June 2009

Meta

  • Log in
Top WordPress
Copyright © 2009-2010 Mindtonic
Theme by NeoEase. Valid XHTML 1.1 and CSS 3.