MS Word Change Date Format

Anonymous
2023-12-21T20:32:57+00:00

Using the latest version of Word, I received a document in which it is all text, ie: no fields. Is there a way that I can find all text in the format dd/mm/yyyy, tell Word this is a date in that format and then have it converted to dd MMM yyyy and still retain it as raw text. In essence, I would like to change text that looks like a date and change that text to another date format. Thanks.

Microsoft 365 and Office | Word | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments
{count} votes
Answer accepted by question author
  1. Doug Robbins - MVP - Office Apps and Services 322.1K Reputation points MVP Volunteer Moderator
    2023-12-22T01:37:09+00:00

    You can do it with a macro containing the following code

    Dim strDay As String, strMonth As String, strYear As String, strMonthText As String

    Selection.HomeKey wdStory

    With Selection.Find

    Do While .Execute(FindText:="[0-9]{2}\/[0-9]{2}\/[0-9]{4}", Forward:=True, \_ 
    
    MatchWildcards:=True, Wrap:=wdFindStop, MatchCase:=True) = True 
    
        strDay = Left(Selection, 2) 
    
        strMonth = Mid(Selection, 4, 2) 
    
        strYear = Right(Selection, 4) 
    
        Select Case strMonth 
    
            Case "01" 
    
                strMonthText = " January " 
    
            Case "02" 
    
                strMonthText = " February " 
    
            Case "03" 
    
                strMonthText = " March " 
    
            Case "04" 
    
                strMonthText = " April " 
    
            Case "05" 
    
                strMonthText = " May " 
    
            Case "06" 
    
                strMonthText = " June " 
    
            Case "07" 
    
                strMonthText = " July " 
    
            Case "08" 
    
                strMonthText = " August " 
    
            Case "09" 
    
                strMonthText = " September " 
    
            Case "10" 
    
                strMonthText = " October " 
    
            Case "11" 
    
                strMonthText = " November " 
    
            Case "12" 
    
                strMonthText = " December " 
    
        End Select 
    
        Selection.Text = strDay & strMonthText & strYear 
    
        Selection.Collapse wdCollapseEnd 
    
    Loop 
    

    End With

    2 people found this answer helpful.
    0 comments No comments

4 additional answers

Sort by: Most helpful
  1. Jay Freedman 206.1K Reputation points Volunteer Moderator
    2023-12-22T01:59:19+00:00

    You can use the following macro, with some caution. (See https://www.gmayor.com/installing_macro.htm if needed.)

    Sub ReformatDates() 
    
        Dim rng As Range 
    
        Dim bFormatErr As Boolean 
    
        Set rng = ActiveDocument.Range 
    
        With rng.Find 
    
            .MatchWildcards = True 
    
            .Text = "[0-9]{1,2}/[0-9]{1,2}/[0-9]{4}" 
    
            .Wrap = wdFindStop 
    
            While .Execute 
    
                If IsDate(rng.Text) Then 
    
                    rng.Text = Format(rng.Text, "dd mmm yyyy") 
    
                Else 
    
                    rng.HighlightColorIndex = wdBrightGreen 
    
                    bFormatErr = True 
    
                End If 
    
                rng.Collapse wdCollapseEnd 
    
                DoEvents 
    
            Wend 
    
            If bFormatErr Then 
    
                MsgBox "At least one date is not valid, highlighted in green.", vbExclamation 
    
            End If 
    
        End With 
    
    End Sub 
    

    The caution is that the Format function operates correctly when the day number is 12 or less only if the Windows regional setting for short dates is set to dd/mm/yyyy [for example, English (United Kingdom) or English (Canada)]. However, if the setting is mm/dd/yyyy as in English (United States), the result will mistakenly appear with the intended day number converted to a month and the intended month number converted to a day. That is, the text 8/4/2023 would be replaced with 08 Apr 2023 for the Canadian setting, but 04 Aug 2023 for the US setting.

    [Edit: I didn't see Doug's post until after I finished mine. His method avoids the concern about the Format function.]

    1 person found this answer helpful.
    0 comments No comments
  2. Anonymous
    2023-12-22T02:28:00+00:00

    In the latest version of Word, if you have received a document that consists only of text without any fields, you can follow these steps to find all the text in the format dd/mm/yyyy, inform Word that it is a date in that format, and then convert it to the format dd MMM yyyy while still retaining it as raw text.

    Please follow these steps:

    1. Open your Word document.
    2. Select the "Home" tab from the top menu bar.
    3. In the "Editing" group, click on "Find".
    4. In the pop-up Find dialog box, click on the "Replace" tab.
    5. In the "Find what" text box, enter the original format of the date, i.e., dd/mm/yyyy.
    6. In the "Replace with" text box, enter the new date format you desire, i.e., dd MMM yyyy.
    7. Click on the "Replace All" button, and Word will find all the matching text and replace it.

    Please note that this replacement will change the text format to the new date format while still keeping it as raw text. This means you can continue editing these date texts as needed without converting them into date fields.

    I hope this answer is helpful to you! If you have any further questions, feel free to ask.

    0 comments No comments
  3. Charles Kenyon 160.1K Reputation points Volunteer Moderator
    2023-12-22T03:52:19+00:00

    Just one nit to pick...

    To get the dd MMM yyyy format, change the text to the three-character abbreviations for the months.

    1 person found this answer helpful.
    0 comments No comments
  4. Doug Robbins - MVP - Office Apps and Services 322.1K Reputation points MVP Volunteer Moderator
    2023-12-23T12:59:01+00:00

    @好骥杨

    That will not do anything.

    1 person found this answer helpful.
    0 comments No comments