August 31, 20187 yr Author Thanks, works great. However, I can I save the number of weeks as a global variable to use in another calculation.
September 2, 20187 yr Hello, Number of weeks equal number of tuesdays ? So you could set in the end of the script $$nb_weeks = $nb_tuesdays Tom
September 3, 20187 yr It depends. See this: https://www.convertunits.com/dates/howmany/Tuesdays-in-2017 So most of the times the number of weeks is the number of Tuesdays (52), but not always, it can sometimes be 53.
September 3, 20187 yr Hey, You get the year, so you get the last day so you could make a calculation WeekNumber(last day of the year) it would 52 or 53 you're right Tom
September 3, 20187 yr A year has either 365 or 366 days. In the first 364 days, there will always be 52 Tuesdays. That's because 364 days are 52 periods of 7 days each, and each of those periods will contain one Tuesday, regardless of which day the year started. Now, a year will have 53 Tuesdays if either day #365 or #366 is a Tuesday. You can test for this by checking if the year starts on a Tuesday (if it does, then day #365 is also a Tuesday), or if the year ends on a Tuesday (if it does, then either day #365 is a Tuesday, or the year is a leap year and day #366 is a Tuesday): Let ( [ first = Date ( 1 ; 1 ; Year ) ; last = Date ( 12 ; 31 ; Year ) ] ; 52 + ( DayOfWeek ( first ) = 3 or DayOfWeek ( last ) = 3 ) ) 15 hours ago, Tom Assia said: you could make a calculation WeekNumber(last day of the year) it would 52 or 53 Actually, that would return either 53 or 54. In any case, it wouldn't tell you anything about the number of Tuesdays in that year. Edited September 3, 20187 yr by comment
Create an account or sign in to comment