How to return the date of a specific day of the month?
We have a calendar that has tasks that occur every Sunday of the month. We would like to be able to set the first day of the month and have each start day return the 1st Sunday of the month, the 2nd Sunday of the month, etc. And we would also like to be able to edit this formula for each day of the week. Not sure where to start, so any help is appreciated.
Answers
-
How are you wanting to structure this? Would all of the dates be listed down a single column, or are you wanting each date in a different column with the month and day of week on each row?
-
The dates would be in a single column (Start Date), and we would have one row at the top that would be the date the formula is based off of. This is our template, and the Tasks/Roles never change.
-
You will need a helper column (called "Number" in this example) that has the numbers 1 - 5 the way it shows in the snippet at the bottom of this comment. You can repeat the numbers as many times as needed, and I do suggest going down through 5. I am also assuming that you will have somewhere to enter a number that represents the day of the week (Sunday = 1, Monday = 2, etc.). That can be seen in the snippet as well.
Then the formula that would go in the Start Date column on the second row and dragfilled down would be:
=IF(MONTH(DATE(YEAR([Start Date]$1), MONTH([Start Date]$1), 1) + (IF(WEEKDAY(DATE(YEAR([Start Date]$1), MONTH([Start Date]$1), 1)) <= [Weekday Number]$1, [Weekday Number]$1, [Weekday Number]$1 + 7) - WEEKDAY(DATE(YEAR([Start Date]$1), MONTH([Start Date]$1), 1))) + (7 * (Number@row - 1))) = MONTH([Start Date]$1), DATE(YEAR([Start Date]$1), MONTH([Start Date]$1), 1) + (IF(WEEKDAY(DATE(YEAR([Start Date]$1), MONTH([Start Date]$1), 1)) <= [Weekday Number]$1, [Weekday Number]$1, [Weekday Number]$1 + 7) - WEEKDAY(DATE(YEAR([Start Date]$1), MONTH([Start Date]$1), 1))) + (7 * (Number@row - 1)))
Help Article Resources
Categories
- All Categories
- 14 Welcome to the Community
- Customer Resources
- 64.8K Get Help
- 434 Global Discussions
- 138 Industry Talk
- 470 Announcements
- 4.9K Ideas & Feature Requests
- 129 Brandfolder
- 148 Just for fun
- 65 Community Job Board
- 486 Show & Tell
- 33 Member Spotlight
- 2 SmartStories
- 300 Events
- 36 Webinars
- 7.3K Forum Archives
Check out the Formula Handbook template!