calculate total work experience by Position Field

Discussion in 'PHP' started by Mariam, Jun 23, 2010.

  1. Mariam

    Mariam New Member

    Joined:
    Sep 9, 2007
    Messages:
    17
    Likes Received:
    0
    Trophy Points:
    0
    have users work experience in database
    Position Field, Employment Period(from,to)

    IT Jan 1982 - Feb 1984
    Advertizing Mar 1985 - Feb 1990
    IT Jan 1990 - May 2002
    IT Jan 2007 - Aug 2007

    I need to calculate total work experience in IT, Advertizing.........

    and I need to get values in this vay for example IT- 12.8 it means that 12 years and 8 month in IT.
     
  2. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,375
    Likes Received:
    388
    Trophy Points:
    83
    Fetch all the dates and arrange them in chronological order and then get the time between first and last.
     
  3. Mariam

    Mariam New Member

    Joined:
    Sep 9, 2007
    Messages:
    17
    Likes Received:
    0
    Trophy Points:
    0
    It will no work properly.

    What if I have

    IT Jan 1982 - Feb 1985
    IT Jan 1983 - May 1986
    IT Jan 2001 - Aug 2007

    You say 2007-1982=25
    but the correct is 10
     
  4. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,375
    Likes Received:
    388
    Trophy Points:
    83
    Was he sleeping between 86 and 2001?

    But anyway then you have to be adding each row.
     
  5. Mariam

    Mariam New Member

    Joined:
    Sep 9, 2007
    Messages:
    17
    Likes Received:
    0
    Trophy Points:
    0
    Yes he was sleeping between 86 and 2001.
     
  6. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,375
    Likes Received:
    388
    Trophy Points:
    83
    Then add the difference between each row.

    i.e end - start and then sum all for total experience
     
  7. Mariam

    Mariam New Member

    Joined:
    Sep 9, 2007
    Messages:
    17
    Likes Received:
    0
    Trophy Points:
    0
    Look if I have

    IT Jan 1982 - Feb 1985
    IT Jan 1983 - May 1986

    1985-1982=3
    1986-1983=3
    I sum up and get 6.
    But 4 is correct answer.
     
  8. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,375
    Likes Received:
    388
    Trophy Points:
    83
    But then you are not just add each years that way. His year of work should not overlap as well so you have to make addition like this.

    1982 12 months
    1983 12 months
    1984 12 months
    1985 12 months
    1986 5 months

    And this would give you results.

    You have to b adding months for each year and then see how many months he has actually worked for the whole of his life.

    This would mean if he is not working for few years that months would also go away.
     
  9. Mariam

    Mariam New Member

    Joined:
    Sep 9, 2007
    Messages:
    17
    Likes Received:
    0
    Trophy Points:
    0
    I need an example. I have already tried different way, but unsuccessfully.:embarasse

    There are times that some months,years are missed.
     
  10. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,375
    Likes Received:
    388
    Trophy Points:
    83
    Say You have a GRID where each row is a year and each column is a month.

    Now from 1982 to 1986 loop through all the months and see if that month he was working or not and if he was then assign a flag in the grid.

    No of flags in the grid is the total number of months he has worked for.
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice