Jump to content

Check week number in end of year and begiining of new year?


AndieB

Recommended Posts

Hi all!

 

I am creating a little own calendar.

Now I want to add a "previous week" and "next week" functionality to the calendar.

 

It is easy to take $thisWeek - 1; and $thisWeek + 1;, but there has to be a check wether it is the last week of the year and it should actually be a new year and head to week number 1.

 

HOW do I make this kind of function?

 

I use the following string names:

$thisYear

$thisWeek

 

Thanks a lot for you help!

 

Sincerely,

Andreas

There isn't an easy solution to what you're after for this reason: weeks go from Sunday through Saturday, and the dates of the year very seldom overlap exactly with the week. So, if January 1 falls on Wednesday, you could accurately report it as either week 52 (for Sunday through Tuesday) or week 1 of the following year (for Wednesday through Saturday).

 

Either way, simply grabbing weeks of the year is a little more difficult than simply checking what week of the year the current week is. Can you maybe define a few more rules for what you're after? If you can, I'm sure we can help you come up with a solution.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.