Using EDATE & WORKDAY Together With Numbers.

I am trying to include an EDATE function into a WORDAY formula. In the showcased exemple, I am trying to find the closest workday 2 years ago from today. Here is my formula:


WORKDAY(EDATE(TODAY(),−24)−1,0,NYSE MARKET HOLIDAYS::B2:E11)


Today is Sept. 3rd. 2025. The formula returns Sept. 2nd. 2023 which happens to be a Saturday.


I am subtracting 1 to the EDATE function, which is apparently a trick to make the EDATE function work in a WORKDAY formula. I tried without and the formula returns Sept. 3rd. 2023 which is a Sunday.


Notice I'm also excluding holidays which have been entered in another table. That part seems to work fine, though. But the WORKDAY formula is clearly not excluding weekends properly in this case. I'm sure I'm doing something wrong. Looking forward to finding a solution. Thanks!




[Edited by Moderator]

MacBook Pro 13″, macOS 15.6

Posted on Sep 3, 2025 11:59 AM

Reply
Question marked as Top-ranking reply

Posted on Sep 3, 2025 12:42 PM

I think WORKDAY()'s second parameter being zero is undefined.


Indeed, the help states:


> work-days: A number value representing the number of working days. work-days is a positive value if the desired date is after date and a negative value if the desired date is before date.


It has no provision for 0, which seems to be interpreted as 'return the exact date', which kind of makes sense since you're not asking for the next (or previous) workday.


Given your desire to return '... the closest workday', you may have to jump through some additional hoops to work out whether you want the next or the previous day.


For example, here's one solution that uses LET() to break out the individual hoops:


=LET(dayofweek,DAYNAME(WORKDAY(EDATE(TODAY(),−24),0,NYSE Market Holidays::B2:B11)),

     dateOffset,IFS(dayofweek="Sunday",1,dayofweek="Saturday",−1,TRUE,0),

     WORKDAY(EDATE(TODAY(),−24),dateOffset,NYSE Market Holidays::B2:B11))


I'll break out the steps:


    dayofweek, DAYNAME(WORKDAY(EDATE(TODAY(),−24),0,NYSE Market Holidays::B2:B11))


Calculates the day name for the dates 24 months ago. This is stored in the variable dayofWeek.


     dateOffset,IFS(dayofweek="Sunday",1,dayofweek="Saturday",−1,TRUE,0),



This uses the IFS() statement to check a series of TRUE/FALSE values and returns the corresponding first match.

It checks if dayofweek (as just defined in the previous line) is Sunday (in which case dateOffset is set to 1) or if dayofweek is set to "Saturday" (in which case dateOffset is set to -1). Any other value sets dateOffset to 0).


Now we know if we want to add a day or subtract a day (or keep the day as-is), so we can re-run the WORKDAY() function with the appropriate offset:


     WORKDAY(EDATE(TODAY(),−24),dateOffset,NYSE Market Holidays::B2:B11)


LET() is included in Numbers 14.4 and later. if you have an older version, the same thing can be achieved, it's just that LET() makes it a lot more readable.

6 replies
Question marked as Top-ranking reply

Sep 3, 2025 12:42 PM in response to GFIVE

I think WORKDAY()'s second parameter being zero is undefined.


Indeed, the help states:


> work-days: A number value representing the number of working days. work-days is a positive value if the desired date is after date and a negative value if the desired date is before date.


It has no provision for 0, which seems to be interpreted as 'return the exact date', which kind of makes sense since you're not asking for the next (or previous) workday.


Given your desire to return '... the closest workday', you may have to jump through some additional hoops to work out whether you want the next or the previous day.


For example, here's one solution that uses LET() to break out the individual hoops:


=LET(dayofweek,DAYNAME(WORKDAY(EDATE(TODAY(),−24),0,NYSE Market Holidays::B2:B11)),

     dateOffset,IFS(dayofweek="Sunday",1,dayofweek="Saturday",−1,TRUE,0),

     WORKDAY(EDATE(TODAY(),−24),dateOffset,NYSE Market Holidays::B2:B11))


I'll break out the steps:


    dayofweek, DAYNAME(WORKDAY(EDATE(TODAY(),−24),0,NYSE Market Holidays::B2:B11))


Calculates the day name for the dates 24 months ago. This is stored in the variable dayofWeek.


     dateOffset,IFS(dayofweek="Sunday",1,dayofweek="Saturday",−1,TRUE,0),



This uses the IFS() statement to check a series of TRUE/FALSE values and returns the corresponding first match.

It checks if dayofweek (as just defined in the previous line) is Sunday (in which case dateOffset is set to 1) or if dayofweek is set to "Saturday" (in which case dateOffset is set to -1). Any other value sets dateOffset to 0).


Now we know if we want to add a day or subtract a day (or keep the day as-is), so we can re-run the WORKDAY() function with the appropriate offset:


     WORKDAY(EDATE(TODAY(),−24),dateOffset,NYSE Market Holidays::B2:B11)


LET() is included in Numbers 14.4 and later. if you have an older version, the same thing can be achieved, it's just that LET() makes it a lot more readable.

Sep 3, 2025 8:31 PM in response to Camelot

I really appreciate all the effort you put into this. Thanks to your explanations and your table (which I reproduced), I was able to figure it out. The formula works just fine but this weekend being a holiday weekend, a lot of my cells weren't populating correctly. The reason was simply because my exclusions didn't go as far as 10 years. I went back all the way to 10 years and all is well. Thanks again 🙏

Sep 4, 2025 4:41 AM in response to GFIVE

Not to throw a wrench in the works, only to point out the potential for a wrong answer, there appears to be a bug in the WORKDAY function where if the date in the formula is one of the skip days it will skip an extra day rather than give you the next/previous workday. In the example below, 9/3/25 is a Wednesday. The previous workday is 9/2 and the next is 9/4 but if 9/3 is an excluded date (the formula includes the skip dates though the header doesn't show that) it provides an incorrect answer. I entered a bug report over three years ago but this bug has remained through multiple versions of Numbers since then.



Sep 4, 2025 6:14 AM in response to Badunit

...and it wouldn't hurt if more people informed Apple about this bug. Maybe, just maybe, if it gets enough light they might possibly start to consider thinking about one day looking into it and whether it is something they would want to fix if they ever think it is of any priority at all and if they find the time to do so. For all I know they threw out my report.


Numbers->Provide Numbers Feedback

Sep 3, 2025 1:50 PM in response to Camelot

Hey. I really appreciate your reply and a way to make this work. That's definitely a sure way to go about this. However, I am very curious as to why my formula isn't working. You do mention the "0" in my formula. I've tried with "+1" and "-1" which once again, doesn't skip weekends. That's a real head scratcher. I'll give the internet a few days to see if something has an explanation for this. But I'll probably end up using your solution. Thanks again!

Sep 3, 2025 2:21 PM in response to GFIVE

> You do mention the "0" in my formula. I've tried with "+1" and "-1" which once again, doesn't skip weekends.


Can you post your formula?


In checking here, WORKDAY() does seem to return Monday (1) or Friday (-1) for a date that falls on the weekend. I can't get it not to.


Here's a quick table I threw together to show the WEEKDAY() 1 and -1 values for a set of dates:



The only difference is the lack of skip dates.


Either way, though, since you want the closest day, you're still going to have to address how to work out the +1 or -1 offset for WORKDAY()

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Using EDATE & WORKDAY Together With Numbers.

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.