Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 1
Default CALCULATE DAYS PER MONTH BETWEEN 2 DATES

I am trying to calculate days between a start date and end date for each
month. If start date and end date are same day, formula should return 1.
Columns A-AD are in use for other data. Below is an example of what I want to
see. Help, please?

Example:
A B ... N €¦ R S T €¦ AB AC
1 Start End JAN FEB MAR NOV DEC
2 1/2/09 1/2/09 1
3 1/16/09 3/27/09 16 28 27
4 2/3/09 3/11/09 26 11
5 11/13/09 12/13/09 18 13
6 1/12/09 12/1/09 20 28 31 30 1


  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 913
Default CALCULATE DAYS PER MONTH BETWEEN 2 DATES

On Thu, 30 Jul 2009 12:16:01 -0700, wildliferehabber
wrote:

I am trying to calculate days between a start date and end date for each
month. If start date and end date are same day, formula should return 1.
Columns A-AD are in use for other data. Below is an example of what I want to
see. Help, please?

Example:
A B ... N … R S T … AB AC
1 Start End JAN FEB MAR NOV DEC
2 1/2/09 1/2/09 1
3 1/16/09 3/27/09 16 28 27
4 2/3/09 3/11/09 26 11
5 11/13/09 12/13/09 18 13
6 1/12/09 12/1/09 20 28 31 30 1



With the start date in cell A2 and the end date in cell B2, try the
following in cell C2:

=SUMPRODUCT(--(DATE(YEAR($A2),COLUMN(A1),
ROW(OFFSET($A1,,,DAY(DATE(YEAR($A2),COLUMN(B1),0)) ,)))=$A2))
-SUMPRODUCT(--(DATE(YEAR($A2),COLUMN(A1),
ROW(OFFSET($A1,,,DAY(DATE(YEAR($A2),COLUMN(B1),0)) ,)))$B2))

Copy this formula to the right thru cell N2.
Then copy cells C2:N2 down as far as you have data in columns A and B.

Note: This formula will only work if there is only one calendar year
involved, i.e. the start date and end date within the same year.

Hope this helps / Lars-Åke


  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 1
Default CALCULATE DAYS PER MONTH BETWEEN 2 DATES


If your header row contains dates, i.e. the 1st of each month (you can
custom format these as mmm if you just want to display "Jan","Feb" etc.)
then you can use this formula in C2 copied across and down

=MAX(0,MIN($B2,C$1+31-DAY(C$1+31))-MAX($A2,C$1)+1)


--
barry houdini
------------------------------------------------------------------------
barry houdini's Profile: http://www.thecodecage.com/forumz/member.php?userid=72
View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=121159

  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 913
Default CALCULATE DAYS PER MONTH BETWEEN 2 DATES

On Thu, 30 Jul 2009 23:14:06 +0100, barry houdini
wrote:


If your header row contains dates, i.e. the 1st of each month (you can
custom format these as mmm if you just want to display "Jan","Feb" etc.)
then you can use this formula in C2 copied across and down

=MAX(0,MIN($B2,C$1+31-DAY(C$1+31))-MAX($A2,C$1)+1)


This is nice. However, be aware the limitation that the start and end
dates must be within the calendar year that you have used for the
header row dates.
When you have a new year you will need a new header row.

Lars-Åke
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
Calculate days in a month N Harkawat Excel Worksheet Functions 2 September 16th 08 08:46 PM
Calculate days in each month PVS Excel Worksheet Functions 8 March 27th 08 11:22 AM
How to calculate days in the month RJ Swain Excel Discussion (Misc queries) 5 February 20th 08 12:41 PM
How to calculate a date: first day of the month after 60 days Claudia Excel Discussion (Misc queries) 12 June 28th 07 05:10 AM
Calculate Days in a Month LGG Excel Discussion (Misc queries) 6 January 13th 06 06:31 PM


All times are GMT +1. The time now is 02:12 PM.

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"