Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 10
Default Excluding leap days in a formula

Is there an excel function which could subtract (-1) from a formula if the
dates included the leap day? I don't want to count that one additional day
in a leap year; I know I can include a -1 in my formula, but I'm looking for
something that will decide if it's a leap year and automatically subtract it
from my date difference formula.


  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 5,651
Default Excluding leap days in a formula

On Thu, 11 Dec 2008 05:05:00 -0800, PMBO
wrote:

Is there an excel function which could subtract (-1) from a formula if the
dates included the leap day? I don't want to count that one additional day
in a leap year; I know I can include a -1 in my formula, but I'm looking for
something that will decide if it's a leap year and automatically subtract it
from my date difference formula.


Your formula can be altered to not count Feb 29. Post your formula and someone
will show you how to account for that.
--ron
  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 10
Default Excluding leap days in a formula

Ron -
I'm using a simple datedif =DATEDIF(A1,A2,"d")

"Ron Rosenfeld" wrote:

On Thu, 11 Dec 2008 05:05:00 -0800, PMBO
wrote:

Is there an excel function which could subtract (-1) from a formula if the
dates included the leap day? I don't want to count that one additional day
in a leap year; I know I can include a -1 in my formula, but I'm looking for
something that will decide if it's a leap year and automatically subtract it
from my date difference formula.


Your formula can be altered to not count Feb 29. Post your formula and someone
will show you how to account for that.
--ron

  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 8,651
Default Excluding leap days in a formula

I'm not sure why you are using =DATEDIF(A1,A2,"d") instead of =A2-A1, but it
may be worth trying:
=(YEAR(A2)-YEAR(A1)-((YEAR(A2)-YEAR(A1))DATEDIF(A1,A2,"y")))*365+DATEDIF(A1,A2," yd")You may, of course, be able to simplify that.I assume that if there is more than one Feb 29 in the period, you want tosubtract one for each?--David Biddulph"PMBO" wrote in ... Ron - I'm using a simple datedif =DATEDIF(A1,A2,"d") "Ron Rosenfeld" wrote: On Thu, 11 Dec 2008 05:05:00 -0800, PMBO wrote: Is there an excel function which could subtract (-1) from a formula ifthe dates included the leap day? I don't want to count that one additionalday in a leap year; I know I can include a -1 in my formula, but I'm lookingfor something that will decide if it's a leap year and automaticallysubtract it from my date difference formula. Your formula can be altered to not count Feb 29. Post your formula andsomeone will show you how to account for that. --ron

  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 10
Default Excluding leap days in a formula

You're right - I changed it to the simplier formula, but I tested your
formula on dates 2/1/2008 to 3/1/2008 = 29 days and 2/1/2009 to 3/1/2009 = 28
days. I don't want it to count that leap day. Any other ideas?


"David Biddulph" wrote:

I'm not sure why you are using =DATEDIF(A1,A2,"d") instead of =A2-A1, but it
may be worth trying:
=(YEAR(A2)-YEAR(A1)-((YEAR(A2)-YEAR(A1))DATEDIF(A1,A2,"y")))*365+DATEDIF(A1,A2," yd")You may, of course, be able to simplify that.I assume that if there is more than one Feb 29 in the period, you want tosubtract one for each?--David Biddulph"PMBO" wrote in ... Ron - I'm using a simple datedif =DATEDIF(A1,A2,"d") "Ron Rosenfeld" wrote: On Thu, 11 Dec 2008 05:05:00 -0800, PMBO wrote: Is there an excel function which could subtract (-1) from a formula ifthe dates included the leap day? I don't want to count that one additionalday in a leap year; I know I can include a -1 in my formula, but I'm lookingfor something that will decide if it's a leap year and automaticallysubtract it from my date difference formula. Your formula can be altered to not count Feb 29. Post your formula andsomeone will show you how to account

for that. --ron




  #6   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 5,651
Default Excluding leap days in a formula

On Thu, 11 Dec 2008 05:28:06 -0800, PMBO
wrote:

Ron -
I'm using a simple datedif =DATEDIF(A1,A2,"d")



This should work:

=SUMPRODUCT(--(((MONTH(ROW(INDIRECT(StartDt&":"&EndDt)))<2)+
(DAY(ROW(INDIRECT(StartDt&":"&EndDt)))<29))0))

--ron
  #7   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 10
Default Excluding leap days in a formula

Fantastic - It works perfectly. Thank You Ron.

"Ron Rosenfeld" wrote:

On Thu, 11 Dec 2008 05:28:06 -0800, PMBO
wrote:

Ron -
I'm using a simple datedif =DATEDIF(A1,A2,"d")



This should work:

=SUMPRODUCT(--(((MONTH(ROW(INDIRECT(StartDt&":"&EndDt)))<2)+
(DAY(ROW(INDIRECT(StartDt&":"&EndDt)))<29))0))

--ron

  #8   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 5,651
Default Excluding leap days in a formula

On Thu, 11 Dec 2008 13:10:12 -0500, Ron Rosenfeld
wrote:

On Thu, 11 Dec 2008 05:28:06 -0800, PMBO
wrote:

Ron -
I'm using a simple datedif =DATEDIF(A1,A2,"d")



This should work:

=SUMPRODUCT(--(((MONTH(ROW(INDIRECT(StartDt&":"&EndDt)))<2)+
(DAY(ROW(INDIRECT(StartDt&":"&EndDt)))<29))0) )

--ron


A quick note -- the above formula returns an inclusive count. You should
probably subtract one (1) to obtain the result you really want.
--ron
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
Formula for adding days to a date excluding weekends and holidays? Jake via OfficeKB.com Excel Discussion (Misc queries) 3 May 20th 23 07:48 PM
excel total days formula including weekends, excluding holidays wtfisch Excel Discussion (Misc queries) 0 May 7th 08 04:53 PM
Calc days between two dates and exclude leap year days scoz Excel Worksheet Functions 5 November 23rd 07 03:58 PM
Working Days excluding Sundays danh Excel Discussion (Misc queries) 6 March 31st 07 08:52 PM
formula to calculate # of days between dates, excluding holidays abs2299 Excel Discussion (Misc queries) 8 March 3rd 05 02:21 AM


All times are GMT +1. The time now is 01:29 AM.

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"