+ Reply to Thread
Results 1 to 19 of 19

Formula to calculate how many days in a month have Daylight Savings

  1. #1
    Forum Expert kersplash's Avatar
    Join Date
    11-22-2016
    Location
    Perth
    MS-Off Ver
    Home 2016 (Windows 10)/Work 2013 Pro Plus (Windows 10)
    Posts
    2,012

    Formula to calculate how many days in a month have Daylight Savings

    In the attached, the Business Hours column calculates the number of staffed hours per business days in the month.

    The problem I have is when daylight savings is in effect, there are 12 hours per business, and 11 hours per business day when daylight savings is not in effect.

    I need a formula to take into account the change of daylight savings in the Business Hours field.
    Attached Files Attached Files
    Last edited by kersplash; 12-21-2018 at 01:34 AM. Reason: changed title - more appropriate

  2. #2
    Forum Guru Bo_Ry's Avatar
    Join Date
    09-10-2018
    Location
    Thailand
    MS-Off Ver
    MS 365
    Posts
    7,211

    Re: Formula to calculate differently depending on number of days in month in/out of DST

    Please try at D2

    =[@[Month Business Days]]*12-((MONTH(A2)>=MONTH($O$2))+(MONTH(A2)<=MONTH($P$2)))*NETWORKDAYS(MAX(EOMONTH(A2,-1)+1,$O$2),MIN(EOMONTH(A2,0),$P$2),tbl_PH[P/H])
    Attached Files Attached Files

  3. #3
    Forum Expert kersplash's Avatar
    Join Date
    11-22-2016
    Location
    Perth
    MS-Off Ver
    Home 2016 (Windows 10)/Work 2013 Pro Plus (Windows 10)
    Posts
    2,012

    Re: Formula to calculate differently depending on number of days in month in/out of DST

    Thanks for the formula Bo_Ry.

    I would like this to include future daylight savings times as well which will be listed in the Daylight Savings Table.

  4. #4
    Forum Guru Bo_Ry's Avatar
    Join Date
    09-10-2018
    Location
    Thailand
    MS-Off Ver
    MS 365
    Posts
    7,211

    Re: Formula to calculate differently depending on number of days in month in/out of DST

    kersplash,

    Is the daylight savings will be between Oct - Apr every year?

  5. #5
    Forum Expert kersplash's Avatar
    Join Date
    11-22-2016
    Location
    Perth
    MS-Off Ver
    Home 2016 (Windows 10)/Work 2013 Pro Plus (Windows 10)
    Posts
    2,012

    Re: Formula to calculate differently depending on number of days in month in/out of DST

    Also your formula results in the same number of hours as 12 x Month Business Days for July, but July is outside of Daylight Savings so should be 11 x Month Business Days.

  6. #6
    Forum Expert kersplash's Avatar
    Join Date
    11-22-2016
    Location
    Perth
    MS-Off Ver
    Home 2016 (Windows 10)/Work 2013 Pro Plus (Windows 10)
    Posts
    2,012

    Re: Formula to calculate differently depending on number of days in month in/out of DST

    Quote Originally Posted by Bo_Ry View Post
    kersplash,

    Is the daylight savings will be between Oct - Apr every year?
    Daylight Saving Time begins at 2am on the first Sunday in October, when clocks are put forward one hour. It ends at 2am (which is 3am Daylight Saving Time) on the first Sunday in April, when clocks are put back one hour.

  7. #7
    Forum Guru Bo_Ry's Avatar
    Join Date
    09-10-2018
    Location
    Thailand
    MS-Off Ver
    MS 365
    Posts
    7,211

    Re: Formula to calculate differently depending on number of days in month in/out of DST

    Please try at F2

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



    O2
    =WORKDAY.INTL(--("oct"&LEFT(N2,4)),1,"1111110")

    E2
    =WORKDAY.INTL(--("apr"&LEFT(N2,4)+1),1,"1111110")
    Attached Files Attached Files

  8. #8
    Forum Guru Bo_Ry's Avatar
    Join Date
    09-10-2018
    Location
    Thailand
    MS-Off Ver
    MS 365
    Posts
    7,211

    Re: Formula to calculate differently depending on number of days in month in/out of DST

    Quote Originally Posted by kersplash View Post
    Also your formula results in the same number of hours as 12 x Month Business Days for July, but July is outside of Daylight Savings so should be 11 x Month Business Days.
    Oh, I invert for daylight count for 11 hr.

  9. #9
    Forum Guru Bo_Ry's Avatar
    Join Date
    09-10-2018
    Location
    Thailand
    MS-Off Ver
    MS 365
    Posts
    7,211

    Re: Formula to calculate differently depending on number of days in month in/out of DST

    Please try again at F2

    =[@[Month Business Days]]*11+IFERROR(((MONTH(A2)>=MONTH($P$2))+(MONTH(A2)<=MONTH($Q$2)))*NETWORKDAYS(MAX(EOMONTH(A2,-1)+1,LOOKUP(EOMONTH(A2,0),tbl_DS[Start])),MIN(EOMONTH(A2,0),LOOKUP(EOMONTH(A2,0),tbl_DS[Start],tbl_DS[End])),tbl_PH[P/H]),)
    Last edited by Bo_Ry; 12-21-2018 at 12:16 AM. Reason: corrected formula

  10. #10
    Forum Expert kersplash's Avatar
    Join Date
    11-22-2016
    Location
    Perth
    MS-Off Ver
    Home 2016 (Windows 10)/Work 2013 Pro Plus (Windows 10)
    Posts
    2,012

    Re: Formula to calculate differently depending on number of days in month in/out of DST

    Thanks Bo_Ry. You got me what I needed. Just had to modify your final result slightly. Attached is the final.

    Thankyou.
    Attached Files Attached Files

  11. #11
    Forum Expert kersplash's Avatar
    Join Date
    11-22-2016
    Location
    Perth
    MS-Off Ver
    Home 2016 (Windows 10)/Work 2013 Pro Plus (Windows 10)
    Posts
    2,012

    Re: Formula to calculate differently depending on number of days in month in/out of DST

    Quote Originally Posted by Bo_Ry View Post
    Oh, I invert for daylight count for 11 hr.
    That's what I thought. All fixed. Thanks.

  12. #12
    Forum Expert kersplash's Avatar
    Join Date
    11-22-2016
    Location
    Perth
    MS-Off Ver
    Home 2016 (Windows 10)/Work 2013 Pro Plus (Windows 10)
    Posts
    2,012

    Re: Formula to calculate differently depending on number of days in month in/out of DST

    Hi Bo_Ry.

    Sorry, one more thing the Start Date for 2023 should be 1st October but your formula gives 8th October.

  13. #13
    Forum Guru Bo_Ry's Avatar
    Join Date
    09-10-2018
    Location
    Thailand
    MS-Off Ver
    MS 365
    Posts
    7,211

    Re: Formula to calculate differently depending on number of days in month in/out of DST

    Please try

    =WORKDAY.INTL(--("oct"&LEFT(O2,4))-1,1,"1111110")

    or

    =--("oct"&LEFT(O2,4))-WEEKDAY(("oct"&LEFT(O2,4)),11)+7

  14. #14
    Forum Expert kersplash's Avatar
    Join Date
    11-22-2016
    Location
    Perth
    MS-Off Ver
    Home 2016 (Windows 10)/Work 2013 Pro Plus (Windows 10)
    Posts
    2,012

    Re: Formula to calculate differently depending on number of days in month in/out of DST

    Quote Originally Posted by Bo_Ry View Post
    Please try

    =WORKDAY.INTL(--("oct"&LEFT(O2,4))-1,1,"1111110")

    or

    =--("oct"&LEFT(O2,4))-WEEKDAY(("oct"&LEFT(O2,4)),11)+7
    That works.

    However still when 2017/18 is the year the End date should be 1/4/2018 not 8/4/2018.

  15. #15
    Forum Guru Bo_Ry's Avatar
    Join Date
    09-10-2018
    Location
    Thailand
    MS-Off Ver
    MS 365
    Posts
    7,211

    Re: Formula to calculate differently depending on number of days in month in/out of DST

    Same as Oct

    =WORKDAY.INTL(--("apr"&LEFT(P2,4)+1)-1,1,"1111110")

  16. #16
    Forum Expert kersplash's Avatar
    Join Date
    11-22-2016
    Location
    Perth
    MS-Off Ver
    Home 2016 (Windows 10)/Work 2013 Pro Plus (Windows 10)
    Posts
    2,012

    Re: Formula to calculate differently depending on number of days in month in/out of DST

    Perfect. Thanks again.

  17. #17
    Forum Expert kersplash's Avatar
    Join Date
    11-22-2016
    Location
    Perth
    MS-Off Ver
    Home 2016 (Windows 10)/Work 2013 Pro Plus (Windows 10)
    Posts
    2,012

    Re: Formula to calculate differently depending on number of days in month in/out of DST

    Another problem, the formula now for calculating the number of Daylight Savings Days is broken with those changes. See attached.
    Attached Files Attached Files

  18. #18
    Forum Guru Bo_Ry's Avatar
    Join Date
    09-10-2018
    Location
    Thailand
    MS-Off Ver
    MS 365
    Posts
    7,211

    Re: Formula to calculate how many days in a month have Daylight Savings

    You forgot +1 at Data sheet G2

    =WORKDAY.INTL(--("apr"&LEFT([@[Daylight Savings]],4)+1)-1,1,"1111110")

  19. #19
    Forum Expert kersplash's Avatar
    Join Date
    11-22-2016
    Location
    Perth
    MS-Off Ver
    Home 2016 (Windows 10)/Work 2013 Pro Plus (Windows 10)
    Posts
    2,012

    Re: Formula to calculate how many days in a month have Daylight Savings

    Quote Originally Posted by Bo_Ry View Post
    You forgot +1 at Data sheet G2

    =WORKDAY.INTL(--("apr"&LEFT([@[Daylight Savings]],4)+1)-1,1,"1111110")
    Hi Bo-Ry,

    Thanks but this gives the incorrect dates. The start and end dates are correct and I've worked on a different method in the attached which seems to be working correctly.

    Thanks
    Attached Files Attached Files

+ 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. [SOLVED] Formula to calculate working days and calendar days per month-year ?
    By donny007 in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 11-05-2018, 06:23 PM
  2. [SOLVED] calculate the number of days in a month through 'Month Name'
    By pipsmultan in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 04-30-2017, 03:10 PM
  3. How to calculate number of days between two dates by month
    By MHayward in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 04-06-2015, 12:26 PM
  4. [SOLVED] Calculate number of days in a month between two dates
    By schlomo87 in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-04-2014, 12:32 AM
  5. [SOLVED] How to calculate Year, Month and Day from total number of days?
    By Indra Rai in forum Excel General
    Replies: 4
    Last Post: 06-25-2014, 02:08 PM
  6. Replies: 15
    Last Post: 06-03-2014, 02:08 PM
  7. [SOLVED] Calculate number of days depending on some date criteria
    By rickyilas in forum Excel General
    Replies: 5
    Last Post: 05-23-2012, 10:07 PM

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