+ Reply to Thread
Results 1 to 14 of 14

Calculate the number of winter days between two dates

  1. #1
    Registered User
    Join Date
    12-11-2013
    Location
    France
    MS-Off Ver
    Excel 2010
    Posts
    4

    Question Calculate the number of winter days between two dates

    Hello everybody,

    I'm looking for the formula to calculate the number of winter days between two dates.

    Say, that I'm having:
    - Winter season start date (say Dec 1st)
    - Winter season end date (say, March 1st)

    => All the days which are between these two are considered winter days for any given year.

    - Two different dates defining the beginning and the end of my PERIOD. The total length of the period may be more than one year.

    HOW do I calculate total number of winter days for the PERIOD?

    Thanks a lot!!
    Last edited by evp2; 12-12-2013 at 07:03 AM.

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Calculate the number of winter days between two dates

    Hi,

    Is there any significance to the word 'winter'. Doesn't this question boil down to the number of days between two dates?

    If so with the earlier date in A1 and last date in A2

    =a2-a1

    plus 1 if you want days inclusive or minus 1 if you want exclusive dates.

    Late edit. Ok I see the proviso about more than one year. Ignore the above.
    Last edited by Richard Buttrey; 12-11-2013 at 11:31 AM.
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  3. #3
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2404 Win 11 Home 64 Bit
    Posts
    23,858

    Re: Calculate the number of winter days between two dates

    Try this:

    Data Range
    A
    B
    C
    D
    E
    F
    G
    H
    I
    J
    K
    L
    1
    Start Winter
    End Winter
    Start Date
    End Date
    2
    12/1/2013
    3/1/2014
    1/15/2014
    2/25/2014
    41
    3
    4
    5
    Formula in E2
    6
    '=IF(AND(C2<A2,D2>B2),B2-A2,IF(AND(C2<A2,D2<B2),D2-A2,IF(AND(C2>A2,D2>B2),B2-C2,IF(AND(C2>A2,D2<B2),D2-C2,""))))
    7
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  4. #4
    Forum Expert Ron Coderre's Avatar
    Join Date
    03-22-2005
    Location
    Boston, Massachusetts
    MS-Off Ver
    2013, 2016, O365
    Posts
    6,996

    Re: Calculate the number of winter days between two dates

    Since your date range may include multiple years...
    A1: start date....2013-01-01
    A2: end date....2014-06-30

    C1: winter start...2013-01-01
    D1: winter end....2014-03-01

    This regular formula returns the count of dates that fall in the Winter period(s)
    Please Login or Register  to view this content.
    In the above example, the formula returns: 151

    Is that something you can work with?
    Ron
    Former Microsoft MVP - Excel (2006 - 2015)
    Click here to see the Forum Rules

  5. #5
    Registered User
    Join Date
    12-11-2013
    Location
    France
    MS-Off Ver
    Excel 2010
    Posts
    4

    Re: Calculate the number of winter days between two dates

    Thank you guys for your prompt replys!

    One important detail (I didn't state it explicitely, sorry for that) - the total PERIOD may go on for MULTIPLE years.

    So what I see from solutions, is that I have to create an array of Starts and Ends of winter periods, covering all the span of possible years where the PERIOD may be (I can do that, I know the span, it is 10 years on total, starting from 2014).
    In this case, the solutions from Ron Coderre and from alansidman will work. Thank for that!

    However, do you think an analytical solution can be made, when one doesn't make explicit reference for a winter season in paricular year (2013, 2014, ...) but uses only relative beginning and start dates (Dec 1st, March 1st)?

  6. #6
    Forum Expert Ron Coderre's Avatar
    Join Date
    03-22-2005
    Location
    Boston, Massachusetts
    MS-Off Ver
    2013, 2016, O365
    Posts
    6,996

    Re: Calculate the number of winter days between two dates

    The formula I posted works for multiple years.
    The reason that I used actual dates for the start and end of winter, instead of 1201 and 0301, is this:
    I would still need to convert 1201 and 0301 to something the formula can use for test purposes...This would be that formula, which (IMHO) causes confusion about subtracting 1100 and adding 100 to align dates correctly(but, it's up to you):
    C1: (formated as text) 1201
    D1: (formated as text) 0301

    Formula: copy to clipboard
    Please Login or Register  to view this content.


    Does that help?

  7. #7
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Calculate the number of winter days between two dates

    Here's another approach.

    With -
    Period First Date in B1 and End Date in B2
    Typical Winter Start Date in E1
    Typical Winter End Date in E2

    The number of winter days between your two dates in A1 & A2

    Formula: copy to clipboard
    Please Login or Register  to view this content.


    I'm also attaching a workbook which shows the generalised approach
    Attached Files Attached Files

  8. #8
    Forum Expert Ron Coderre's Avatar
    Join Date
    03-22-2005
    Location
    Boston, Massachusetts
    MS-Off Ver
    2013, 2016, O365
    Posts
    6,996

    Re: Calculate the number of winter days between two dates

    When I run that formula for 2013-01-01 through 2015-06-30, it returns 180...I was expecting 242.
    Am I missing something?

  9. #9
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Calculate the number of winter days between two dates

    Quote Originally Posted by Ron Coderre View Post
    When I run that formula for 2013-01-01 through 2015-06-30, it returns 180...I was expecting 242.
    Am I missing something?
    No Ron, I think it's me!

    Belay that last post. Let me check it.

  10. #10
    Registered User
    Join Date
    12-11-2013
    Location
    France
    MS-Off Ver
    Excel 2010
    Posts
    4

    Re: Calculate the number of winter days between two dates

    Ron, Richard, thanks for your solutions!

    Your formula, Ron, works fine, but only if winter period starts at the beginning of the year (say, from Jan 1st to March 1st).

    However, if it starts from Nov 1st to March 1st, that won't work.
    I think that can be corrected through the shift of the Winter period and the corresponding shift of the Period (basicaly, we add 2 months to all the dates)

    Another difficulty, is that I also needed to count only WORKING days. Overall, my global task was to calculate the number of working days between two dates (that's easy with NETWORKDAYS) and to calculate the proportion of working days during winter period inside this quantity.
    That's important when you calculate the productivity of construction works, since it is lower during winter periods.

    So, I think I'll have to use an array based approach, since I don't see how can I insert NETWORKDAYS function into your formulas.

    Anyway, I won't close the thread for a moment, in case you have some ideas

  11. #11
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2016
    Posts
    14,675

    Re: Calculate the number of winter days between two dates

    Ron's formula works fine for me, winter period doesn't need to be start of the year

    Quote Originally Posted by evp2 View Post
    Another difficulty, is that I also needed to count only WORKING days.
    What constitutes a working day, do you want to exclude just Saturdays and Sundays or holidays too? If you aren't worried about excluding actual holidays then you can use the holiday field in NETWORKDAYS to exclude summer days, e.g. this array formula

    =NETWORKDAYS(A2,B2,IF((TEXT(ROW(INDIRECT(A2&":"&B2)),"mdd")+0>301)*(TEXT(ROW(INDIRECT(A2&":"&B2)),"mdd")+0<1201),ROW(INDIRECT(A2&":"&B2)),0))

    confirmed with CTRL+SHIFT+ENTER

    A2 = start date, B2 = end date and 1201 and 301 in the formula represent the start and end dates of winter, change as required
    Last edited by daddylonglegs; 12-12-2013 at 05:45 AM.
    Audere est facere

  12. #12
    Registered User
    Join Date
    12-11-2013
    Location
    France
    MS-Off Ver
    Excel 2010
    Posts
    4

    Re: Calculate the number of winter days between two dates

    Hey daddylonglegs ,

    love your solution, works perfectly!
    Just had to change "mdd" by "mjj" and "," by ";" since I'm using the French office

    Thanks!

  13. #13
    Registered User
    Join Date
    06-13-2014
    Posts
    3

    Re: Calculate the number of winter days between two dates

    None of these formulas are working for me, and I need to include weekends. The dates are not winter but the "heating season". And I have to put it into 22,000 cells so an array would not be the best option because I do not known how to CTRL+SHIFT+ENTER multiple cells at the same time.
    Start Date..AQ3..5/20/2014
    End Date.....AQ2..1/14/2014

    Season Start..HDD!$K$2..10/1/2013
    Season End....HDD!$L$2..4/1/14

    The answer should be 105 but I get 45

    SUMPRODUCT((TEXT(EDATE(ROW(INDEX(AQ:AQ,AQ3):INDEX(AQ:AQ,AQ2)),-11),"MMDD")>=TEXT(HDD!$K$2-1100,"0000"))*(TEXT(EDATE(ROW(INDEX(AQ:AQ,AQ3):INDEX(AQ:AQ,AQ2)),-11),"MMDD")<=TEXT(HDD!$L$2+100,"0000")))

  14. #14
    Forum Expert
    Join Date
    05-30-2012
    Location
    The Netherlands
    MS-Off Ver
    Office 365
    Posts
    14,987

    Re: Calculate the number of winter days between two dates

    @trilla99

    It is not allowed to start your own question in another one's question.

    Start your own question for this an refer to this topic if you think it is helpfull.

    Please also add an small excel example, without confidential information.

    It is also helpfull if you add the desired result in your file.
    Notice my main language is not English.

    I appreciate it, if you reply on my solution.

    If you are satisfied with the solution, please mark the question solved.

    You can add reputation by clicking on the star * add reputation.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Calculate number of days between dates
    By karl8695 in forum Excel General
    Replies: 1
    Last Post: 05-08-2012, 12:54 PM
  2. calculate number days between dates less Sat and Sun
    By maacmaac in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 08-26-2010, 11:09 AM
  3. [SOLVED] calculate number of days btw dates
    By Nelson in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 03-01-2006, 09:02 PM
  4. Calculate number of days in a column of dates
    By Barbara in forum Excel General
    Replies: 3
    Last Post: 05-25-2005, 11:21 AM
  5. Calculate number of days in a column of dates
    By Barbara in forum Excel General
    Replies: 8
    Last Post: 05-25-2005, 09:55 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1