Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Junior Member
 
Posts: 1
Default number of months and days between two dates without approximation

Hello,
I am stuck on a formula to return (in seperate cells) the number of months and days between two dates. I've tried using DATEDIFF function but it's not giving me the correct number of days unless its a 30 day month. I need it to look at the actual number of days in that month i.e 28 for February.

To give some context I am working on a holiday allowance calculation for new employees. our holiday leave year is 1st april-31st March, 23 days leave. If someone starts on the 22nd October, we would calculate their holiday allowance as (23/12)*5)) + (23/365)*10)). 5 being the number of whole months Nov to March and 10 being the days in October between start on the 22nd and the end of the month on the 31st.

I would like just to be able to put the start date in and the leave year end date and to be able to get out an allowance, without me having to manually work out how many days there are between start date and end of the month each time.

Any ideas?
Thanks!
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 3,872
Default number of months and days between two dates without approximation

Hello,

Am Sun, 2 Dec 2012 13:43:28 +0000 schrieb sluggybuig:

To give some context I am working on a holiday allowance calculation for
new employees. our holiday leave year is 1st april-31st March, 23 days
leave. If someone starts on the 22nd October, we would calculate their
holiday allowance as (23/12)*5)) + (23/365)*10)). 5 being the number of
whole months Nov to March and 10 being the days in October between start
on the 22nd and the end of the month on the 31st.

I would like just to be able to put the start date in and the leave year
end date and to be able to get out an allowance, without me having to
manually work out how many days there are between start date and end of
the month each time.


your start date in A1, the end date in B1:
=23/12*DATEDIF(A1,B1,"M") + 23/365*(1+DAY(EOMONTH(A1,0))-DAY(A1))


Regards
Claus Busch
--
Win XP PRof SP2 / Vista Ultimate SP2
Office 2003 SP2 /2007 Ultimate SP2
  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1,045
Default number of months and days between two dates without approximation

On Sun, 2 Dec 2012 13:43:28 +0000, sluggybuig wrote:


Hello,
I am stuck on a formula to return (in seperate cells) the number of
months and days between two dates. I've tried using DATEDIFF function
but it's not giving me the correct number of days unless its a 30 day
month. I need it to look at the actual number of days in that month i.e
28 for February.

To give some context I am working on a holiday allowance calculation for
new employees. our holiday leave year is 1st april-31st March, 23 days
leave. If someone starts on the 22nd October, we would calculate their
holiday allowance as (23/12)*5)) + (23/365)*10)). 5 being the number of
whole months Nov to March and 10 being the days in October between start
on the 22nd and the end of the month on the 31st.

I would like just to be able to put the start date in and the leave year
end date and to be able to get out an allowance, without me having to
manually work out how many days there are between start date and end of
the month each time.

Any ideas?
Thanks!


For the number of whole months from the date in A2 to the following March 31:
=DATEDIF(EOMONTH(A2-1,0),DATE(YEAR(A2)+(MONTH(A2)3),3,31),"m")

For the number of days worked in the current month:
=EOMONTH(A2,0)-A2+1

Combining to compute the number of vacation days accrued in that first year:
=23/12*DATEDIF(EOMONTH(A2-1,0),
DATE(YEAR(A2)+(MONTH(A2)3),3,31),"m")+
23/365*(EOMONTH(A2,0)-A2+1)


  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1,045
Default number of months and days between two dates without approximation

On Sun, 02 Dec 2012 19:10:15 -0500, Ron Rosenfeld wrote:

For the number of whole months from the date in A2 to the following March 31:
=DATEDIF(EOMONTH(A2-1,0),DATE(YEAR(A2)+(MONTH(A2)3),3,31),"m")

For the number of days worked in the current month:
=EOMONTH(A2,0)-A2+1

Combining to compute the number of vacation days accrued in that first year:
=23/12*DATEDIF(EOMONTH(A2-1,0),
DATE(YEAR(A2)+(MONTH(A2)3),3,31),"m")+
23/365*(EOMONTH(A2,0)-A2+1)


Ooops. A logical error,

Number of vacation days worked in the current month should be
=EOMONTH(A2-1,0)-A2+1

And the combination for the total:

=23/12*DATEDIF(EOMONTH(A2-1,0),
DATE(YEAR(A2)+(MONTH(A2)3),3,31),"m")+
23/365*(EOMONTH(A2-1,0)-A2+1)

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
DETERMINING NUMBER OF DAYS / MONTHS / YEARS BETWEEN TWO DATES Boyertown Casket[_2_] Excel Programming 1 March 17th 09 05:27 PM
Number of Months and Days between 2 dates? Jean Excel Worksheet Functions 3 March 30th 07 04:49 PM
Calculate Number of Months Weeks and Days Between Two Dates [email protected] Excel Worksheet Functions 4 September 22nd 06 01:47 AM
Number of years/months/days between 2 dates Deborah Excel Worksheet Functions 4 July 7th 06 11:24 AM
Number of years, months, days between two dates. Bluenose Excel Worksheet Functions 34 June 30th 05 02:18 PM


All times are GMT +1. The time now is 01:26 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"