You might not receive an email informing you that there is a new reply in a thread you are following. We are working on fixing this as fast as possible. Please make sure to periodically check the conversation to see if there are any updates.
October 31, 2024
Please note, the notification system in the Community is partially broken
You might not receive an email informing you that there is a new reply in a thread you are following. We are working on fixing this as fast as possible. Please make sure to periodically check the conversation to see if there are any updates.
October 14, 2024
Word Top Contributors:
How can I format a date to a week format?
Report abuse
Thank you.
Reported content has been submitted
You could modify one of the field codes in the Word Date Calculation Tutorial to convert the date to the day of the year, divide by 7, and add 1:
{ QUOTE { ASK dt Date: } {SET yd{={dt \@ d}+INT(({dt \@ M}-0.986)*30.575)- IF({dt \@ M}>2,2-(MOD({dt \@ yy},4)=0)- (MOD({dt \@ yyyy},400)=0)+(MOD({dt \@ yy},100)=0),0)}} {=(yd/7)+1 \# 0} }
Alternatively, you could use a macro, with a Quick Access Toolbar button or a MACROBUTTON field to launch it. For example, if the date is in a cell of a Word table, this will change it:
Sub DateToWeekNumber()
Dim rg As Range
If Selection.Information(wdWithInTable) Then
Set rg = Selection.Cells(1).Range
rg.MoveEnd wdCharacter, -1 ' exclude cell marker
If IsDate(rg.Text) Then
rg.Text = "Week " & Format(rg.Text, "ww")
End If
Else
MsgBox "Click on a date in a table cell.", , "Week Number"
End If
End Sub
https://jay-freedman.info
Report abuse
Thank you.
Reported content has been submitted
Was this reply helpful?
Sorry this didn't help.
Great! Thanks for your feedback.
How satisfied are you with this reply?
Thanks for your feedback, it helps us improve the site.
How satisfied are you with this reply?
Thanks for your feedback.
Jay,
I started toying with this earlier and got distracted. Something isn't quite right. Consider:
Sub ScratchMacro()
'A basic Word macro coded by Greg Maxey
Dim oDate As Date
oDate = "12/31/13"
MsgBox Format(oDate, "ww")
End Sub
which returns 53 :-(
The OPs original 12/13/13 returns 50 instead of his expected 49. But I think maybe is should be 50.
***
Death smiles at us all, but all a man can do is smile back.
For more help with Word visit:
http://gregmaxey.com/word_tips.html
Report abuse
Thank you.
Reported content has been submitted
Was this reply helpful?
Sorry this didn't help.
Great! Thanks for your feedback.
How satisfied are you with this reply?
Thanks for your feedback, it helps us improve the site.
How satisfied are you with this reply?
Thanks for your feedback.
Question Info
Last updated January 4, 2024 Views 428 Applies to: