Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Week numbers in MS Word

Status
Not open for further replies.

pr24

Programmer
Nov 23, 2001
66
NO
Does anybody know a way to calculate week numbers in MS Word? I really would like something like the date/time function that updates itself automatically, but only with week numbers.

At the moment I've got the week number in a Excel sheet, and links it into the Word document. But, it does not look pretty, and I also have to remember to update the link from week to week.
 
Hi,

The following field code will do it:
{QUOTE "Today’s date ({DATE \@ "d MMMM yyyy"}) falls in week "
{SET yw {=INT(({DATE \@ d}+INT(({DATE \@ M}-0.986)*30.575)-IF({DATE \@ M}>2,2-(MOD({DATE \@ yy},4)=0)-(MOD({DATE \@ yyyy},400)=0)+(MOD({DATE \@ yy},100)=0),0))/7)+1}}
{=yw \# 0" of the year."}

The above shows the field braces as stndard text braces. You need to enter all the field braces '{}' as pairs via Ctrl-F9 to get this to work. You might find it easier to download my Word document at:
/and modify the code example under 'Find The Day Of The Year For A Given Date' as I have done (by wrapping the day calculation in an INT(("days")/7)+1 expression, plus deleting the ordinal superscripting and a few other minor text changes) to produce the above.

Cheers
 
Thank you very much macropod, I will try it as soon as possible!
 
Thank you very much macropod, I will try it as soon as possible!
 
Hi,

I just noticed that the last line of the field should have read:
{=yw \# 0}" of the year."}

Cheers
 
in VBA it is a little simpler...u can use DatePart, as in:

Msgbox "Today's date falls in week " & DatePart("ww", Now) & "."

gives the week number count from first week of year. but remember first week of jan (no matter how many DAYS) is NOT week 0, but week 1, therefore last week in december = week 53. adjust accordingly.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top