[Webinar] Streamline your web hosting managementRegister Today

x
?
Solved

Calculate years and months from start and end dates

Posted on 2010-04-02
1
Medium Priority
?
768 Views
Last Modified: 2013-11-13
I have a rails employment management app Lets say a user creates a new work history entry. It contains a start and end date. How can i use ruby to calculate the number of months and years the user worked at that company? And also how to calculate the total years experience which is the sum of every work history.

eg work history 1
01-03-10 - 01-03-11
1 year

work history 2
01-03-11 - 01-03-12
1 year

total work experience 2 years
#form
<% form_for [@user, @history] do |f| %>
  <%= f.error_messages %>
  <p>
    <%= f.label :start %><br />
    <%= f.date_select :start %>
  </p>
  <p>
    <%= f.label :end %><br />
    <%= f.date_select :end %>
  </p>
   <p>
    <%= f.label :sector %><br />
    <%= collection_select(:history, :sector_id, Sector.find(:all), :id, :name) %>
   </p>
   <p>
    <%= f.label :company %><br />
    <%= f.text_field :company, :size => 70 %>
  </p>

Open in new window

0
Comment
Question by:depassion
1 Comment
 
LVL 10

Accepted Solution

by:
Andrew Doades earned 2000 total points
ID: 29560696
0

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: narshlob
If you've ever programmed in Ruby and have come across either a proc or a lambda, you might have been wondering what the difference is between the two and when you would use one over the other. This article will try to explain the difference between…
In Ruby, Call or invoke a API DLL library is easily via Win32API class, win32-api gem or other gems. For general DLL API call, there are quite a few references, some good tips list below: http://www.rubytips.org/2008/05/13/accessing-windows-api-fro…
As many of you are aware about Scanpst.exe utility which is owned by Microsoft itself to repair inaccessible or damaged PST files, but the question is do you really think Scanpst.exe is capable to repair all sorts of PST related corruption issues?
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…
Suggested Courses
Course of the Month8 days, 7 hours left to enroll

608 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question