00:00A few moments ago someone came to my desk and he asked me how do you calculate the date of
00:04the
00:05first Sunday of any given month? Well my wheels in the head started turning. I had to find out.
00:11So this is how I do it. So this is the date you want to find the first Sunday of
00:15this month and
00:16the year. The first thing I have to do is to create a date so that it can reflect the
00:20first
00:20of that month and after that get the weekday using the weekday function and the second argument on
00:26the weekday would be 2 to indicate Monday as the first day of the week and after that you're going
00:31to say 7 minus the weekday to indicate number of days for Sunday to come which is going to return
00:37a value of 6. Now all you have to do is to convert this into date using a date function.
00:43The first
00:43argument would be the year followed by month as a second argument and the third argument being the
00:48date you're going to plus 1 because you're going to have to compensate for the first day of the month
00:52and then after that close parenthesis and hit enter and as a test we can use a test function
00:57to get the day of the week for this date.
Comments