## compute years of working experience

General discussions related to php

Moderators: macek, egami, gesf

### compute years of working experience

I want to calculate the total years of working experience of a person

the person just inputs his/her work history(company name, start period, and end period)

ex.
company1 jan-2008 - jan-2010

if this is the case its easy
but for this

company1 April/2008 - May/2012
company2 July/2008 - October/2012
company3 July/2008 - November/2012
company4 July/2008 - January/2012
company5 October/2008 - February/2012
company6 January/2009 - July/2012
company7 April/2009 - September/2012
company8 May/2009 - December/2012
company9 April/2011 - August/2012
company10 August/2011 - August/2012
company11 April/2011 - August/2012
company12 May/2012 - July/2012

the case above is a person with multiple jobs at the same time

as you can see, there are dates that are overlapping

can you help me construct a logic for calculating the years of working experience of a person (with a person with multiple jobs at the same time accounted)

jplus2
New php-forum User

Posts: 87
Joined: Wed May 16, 2012 4:17 pm

### Re: compute years of working experience

for the problem, the company name doesn't matter. just figure the differences between the dates for each line and then total it. you could even do it with objects and a static 'experience' property that is incremented whenever a job is added.
seandisanti
php-forum Fan User

Posts: 838
Joined: Mon Oct 01, 2012 12:32 pm

### Re: compute years of working experience

for the problem, the company name doesn't matter. just figure the differences between the dates for each line and then total it. you could even do it with objects and a static 'experience' property that is incremented whenever a job is added.

yeah thats the way to do it, however for cases above where a person have multiple jobs at the same time

ex
company2 July/2008 - October/2012
company3 July/2008 - November/2012
company4 July/2008 - January/2012

if i try to get the length of days per job (company1, company2 and company3) then i think the result now is not accurate
coz the dates are overlapping each other, in reality, the way to get the real length of work period in the example above is
computing the no. of days for company 3

I need a logic to handle this cases
jplus2
New php-forum User

Posts: 87
Joined: Wed May 16, 2012 4:17 pm

### Re: compute years of working experience

so 50 days working 2 jobs concurrently doesn't count as 100 days worth of experience?
seandisanti
php-forum Fan User

Posts: 838
Joined: Mon Oct 01, 2012 12:32 pm

### Re: compute years of working experience

basically yeah, coz we only count here the actual days of working experience, not the days youve work with a particular company
jplus2
New php-forum User

Posts: 87
Joined: Wed May 16, 2012 4:17 pm

### Re: compute years of working experience

Hi,

If work 30 days 1-jan to 31-jan in 2 company means 60days Experience. Now calculate like this.
paulkkarns
New php-forum User

Posts: 1
Joined: Wed Oct 03, 2012 1:32 am

### Re: compute years of working experience

jplus2 wrote:basically yeah, coz we only count here the actual days of working experience, not the days youve work with a particular company

Ok, in your data, are there periods of inactivity in addition to time worked? if not, you can just break it up by companies, then have a variable for beginning and end, and then check start and end for remaining companies, modifying start/end if new company has earlier start or later finish than already stored.
seandisanti
php-forum Fan User

Posts: 838
Joined: Mon Oct 01, 2012 12:32 pm