Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×

This topic is 2291 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Posted

Thanks, works great. However, I can I save the number of weeks as a global variable to use in another calculation.

Posted

Hello,

Number of weeks equal number of tuesdays ?

So you could set in the end of the script $$nb_weeks = $nb_tuesdays

Tom

Posted

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

Posted (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 by comment
  • Like 2

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.