Home > Steve > Computing

Computing

Steve's
logo

Snippets

With no particular rationale, I have decided to present any computing "things" I know that I feel are worthy of disseminating.


Office

My desktop is fairly old and it runs Office 2003.

Office/Excel

More recent versions of Excel than 2003 have an inbuilt function that returns the ISO Week Number of a date. That week number increments on Mondays and is week 1 on the week containing the first Thursday (the majority of the days in week 1 are in the Thursday year).
=ISOWEEKNUM(date)

Excel 2003 provides a week number function (again it can be set to increment on Mondays), where Jan 1 is always week 1 and weeks may not all have 7 days.
=WEEKNUM(date,2)

The following code resides entirely in one cell, so certain functions get called multiple times. This could be avoided by using multiple cells for the function, but I wanted to use it weekly in a calendar sheet, so one cell was all I would allot.
The word "date" (in lower case) should be replaced by the relevant cell number.


If you want a 2-digit (leading zero) display on a numeric cell you can Format Custom as "00".

As a numeric value (use if you want to autofilter on a range of values)(aligned with text version below):

          =WEEKNUM(date-WEEKDAY(date,3)+3,2)-IF(WEEKDAY(DATE(YEAR(date-WEEKDAY(date,3)+3),1,1),3)>3,1,0) 

As text with a leading zero when less than 10:

=RIGHT(100+WEEKNUM(date-WEEKDAY(date,3)+3,2)-IF(WEEKDAY(DATE(YEAR(date-WEEKDAY(date,3)+3),1,1),3)>3,1,0),2) 

Home > Steve > Computing
Last updated 2023-08-13
This page is part of http://www.stocton.org/
Email: webmaster@stocton.org