View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Ron Rosenfeld Ron Rosenfeld is offline
external usenet poster
 
Posts: 5,651
Default Difference between last date of month and given date

On Fri, 13 Jun 2008 02:42:02 -0700, Nikhil
wrote:

I have a date entered in a cell...15-Apr-08. I want to calculate the no. of
days between 30-Apr-08 and 15-Apr-08. In this case 15 days.

Secondly..i have to pay a monthly sum of say 5000 per month....

i want to calculate the total amount from start date till the 30(31st) of
the previous month

how can i do that....

e.g on 15th Jun, i want to calculate the total amount between 15th Apr. to
31st May.

The amount should work out to (2500+5000) = 7500

Plz help


Note that the last day of the preceding month can be given by the formula:

=A1-DAY(A1)

So:
Days from StartDate to End of Month of the month of the startdate:

=32-DAY(StartDate)-DAY(StartDate-DAY(StartDate)+32)

This does NOT include StartDate. e.g. if StartDate = 1 Apr, the formula will
return 30-1 = 29. If you want to include StartDate in the count, add 1:

=33-DAY(StartDate)-DAY(StartDate-DAY(StartDate)+32)

For the number of days from StartDate to the end of the month prior to some
other date:

=SomeOtherDate - DAY(SomeOtherDate) - StartDate

Again, if you need to include StartDate in the count, add 1.

You will need to give more information on how you are calculating the "total
amount" for an accurate result, especially considering that months can vary in
length from 28-31 days.
--ron