john9210 Posted August 31, 2018 Posted August 31, 2018 I'm looking for a calculation that determines the number of tuesdays in a year.
john9210 Posted August 31, 2018 Author Posted August 31, 2018 Thanks, works great. However, I can I save the number of weeks as a global variable to use in another calculation.
Tom Assia Posted September 2, 2018 Posted September 2, 2018 Hello, Number of weeks equal number of tuesdays ? So you could set in the end of the script $$nb_weeks = $nb_tuesdays Tom
OlgerDiekstra Posted September 3, 2018 Posted September 3, 2018 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.
Tom Assia Posted September 3, 2018 Posted September 3, 2018 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
comment Posted September 3, 2018 Posted September 3, 2018 (edited) 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, 2018 by comment 2
Tom Assia Posted September 4, 2018 Posted September 4, 2018 You're right, but i already answer for counting Tuesdays
Recommended Posts
This topic is 2291 days old. Please don't post here. Open a new topic instead.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now