Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 3,101
Default Number of days in a quarter between two date ranges

I am trying to develop a table that will split a cost over quarters. The data
that I have is:
A B C D
E F G
Base Cost Task Start Task End Task Duration Cost per day 08Total
09Total
728.00 02-Nov-2008 31-May-2009 30.16 3.45 215.17
564.00

The total cost per year takes the percentage of time in that year and then
adds an inflation factor (which is why the total is higher than the base).
What I need to do is write a formula that will split each year into quarters.
In this example all the cost for 08 will be in Q4 etc.

Many thanks for your help
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 9,101
Default Number of days in a quarter between two date ranges

I wrote a UDF to do the calculation. You can easily convert to a formula but
it would be much more complicated.

On worksheet use

=DaysWithinDays(DATE(2008,10,1), DATE(2008,12,31), B2, C2)


In VBA add

Function DaysWithinDays(StartDate, EndDate, ActualStart, ActualEnd)

If (ActualStart StartDate) And (ActualStart < EndDate) Then
If ActualStart < StartDate Then
ActualStart = StartDate
End If
If ActualEnd EndDate Then
ActualEnd = EndDate
End If
DaysWithinDays = Int(ActualEnd - ActualStart)
Else
DaysWithinDays = 0
End If

End Function

"Mike" wrote:

I am trying to develop a table that will split a cost over quarters. The data
that I have is:
A B C D
E F G
Base Cost Task Start Task End Task Duration Cost per day 08Total
09Total
728.00 02-Nov-2008 31-May-2009 30.16 3.45 215.17
564.00

The total cost per year takes the percentage of time in that year and then
adds an inflation factor (which is why the total is higher than the base).
What I need to do is write a formula that will split each year into quarters.
In this example all the cost for 08 will be in Q4 etc.

Many thanks for your help

  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 806
Default Number of days in a quarter between two date ranges

Hello Mike,

If I understand you correctly you want to get the number of days for
each quarter for your date intervals.

Example:
For the date interval 2-Nov-2008 thru 31-May-2009 you want to see 60
days for Q4/2008, 59 days for Q1/2009 and 61 days for Q2/2009.

Put 2-Nov-2008 into cell B2
Enter 31-May-2009 into cell C2
Enter first days of each quarter into cells G1, H1, I1, etc.:
G1: 1-Oct-2008
H1: 1-Jan-2009
I1: 1-Apr-2009
J1: 1-Jul-2009

Now enter into cell G2:
=MAX(0,MIN(H1-1,$C$2)-MAX(G1,$B$2)+1)
and copy across...

Regards,
Bernd
  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 806
Default Number of days in a quarter between two date ranges

Hello Joel,

I would suggest this UDF:
Option Explicit

Function DaysWithinDays(StartDate As Date, EndDate As Date, _
ActualStart As Date, ActualEnd As Date) As Long

If (ActualStart <= EndDate) And (ActualEnd = StartDate) Then
If ActualStart < StartDate Then
ActualStart = StartDate
End If
If ActualEnd EndDate Then
ActualEnd = EndDate
End If
DaysWithinDays = ActualEnd - ActualStart + 1
Else
DaysWithinDays = 0
End If

End Function

Regards,
Bernd
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
Number of days in overlapping date ranges (using array formula?) ajnmx Excel Worksheet Functions 7 August 29th 08 11:21 AM
Counting Days of Week in Date Ranges nospaminlich Excel Worksheet Functions 1 April 14th 08 03:41 PM
business day date from a specific date based on a number of days Jana Excel Worksheet Functions 2 January 2nd 08 06:21 PM
Count of days in a quarter Mahesh Excel Discussion (Misc queries) 6 July 23rd 07 02:53 AM
Excel Formula to calulate number of days passed from date to date K. Mack Excel Discussion (Misc queries) 8 January 4th 07 11:27 PM


All times are GMT +1. The time now is 02:23 AM.

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

About Us

"It's about Microsoft Excel"