Date Month-Year Format: How to Recognize and Extract Month/Year Dates in Text

A practical guide to the month-year date format: common written forms, regex patterns that find them, how to normalize matches to YYYY-MM, and how to check results.

A month-year date names a month and a year but no day, such as "March 2024" or "03/2027". These dates appear in report periods, billing cycles, résumés, and card expiration fields. This guide explains what month-year extraction does, which written forms you are likely to meet, how to match them with regular expressions, and how to check the results so you don't pick up the wrong text or alter the text you mean to keep.

What month-year extraction does

Month-year extraction scans plain text and finds the substrings that express a month and a year. Its input is any text: an email, a log file, a spreadsheet column, or a scanned document converted to text. It can produce one or both of two outputs: the exact matched strings, or a normalized value for each match. A common normalized value is the ISO 8601 calendar-month form YYYY-MM, for example 2024-03. ISO 8601 allows this hyphenated form for a reduced-precision date. It does not allow the run-together form YYYYMM, because that could be mistaken for other date forms.

The scope that matters is what the tool should not match. Full dates that include a day ("March 15, 2024" or "12/03/2024"), version numbers, and fractions can look like month-year dates. A useful extractor skips them, or at least flags them for review.

Extraction only reads the source text. If you also replace dates with a normalized form, write the result to a copy or a new column so that you can compare it with the original.

Common month-year forms

Before you write a pattern, list the forms your text actually contains. The table below shows typical forms. Each sample is an illustrative example, not data from a specific source.

Form | Example | Notes
Full month name + year | March 2024 | Most readable; low ambiguity
Abbreviated month + year | Mar 2024, Sept. 2025 | Period after the abbreviation is optional; "Sept" and "Sep" both occur
Month name, comma, year | March, 2024 | Less common, but seen in formal writing
Numeric month/year | 03/2027, 3/2027 | Common in US forms; leading zero may be missing
Numeric with hyphen or dot | 03-2027, 03.2027 | Dot form collides with decimals and version numbers
Two-digit year | 03/27 | Typical for card expirations (MM/YY); ambiguous elsewhere
ISO year-month | 2024-03 | Year first; already normalized

Step 1: Decide which forms to accept

Pick only the forms your source uses. Each form you add increases the chance of false positives, which are matches that are not really dates. Decide two questions in advance:

  • Two-digit years: "3/24" could mean March 2024 or March 24. In the US, month/day order is the usual reading of a numeric pair. Unless your field is known to be MM/YY, such as a card expiration, flag these matches instead of converting them automatically.
  • Capitalization: month names in English are normally capitalized. A case-sensitive pattern avoids matching the verb "may". It also misses "MARCH 2024" written in all capitals. Pick the trade-off that fits your text.

Step 2: Match numeric month/year

The pattern below matches a month from 1 to 12, with an optional leading zero, followed by a slash, hyphen, or dot and a four-digit year. A lookbehind is a check that looks at the characters just before a match without including them in the match. A lookahead does the same for the characters just after. Here the lookbehind and lookahead stop the pattern from taking a piece of a longer number or a full date like 12/03/2024. Lookbehind is not supported in every regex engine, so check yours.

(?<![0-9/.-])(0?[1-9]|1[0-2])[/.-]([0-9]{4})(?![/.-]?[0-9])

The pattern uses [0-9] instead of \d on purpose. In some engines, Python's re module with text strings among them, \d also matches non-ASCII digits such as Arabic-Indic numerals. Use \d only if you want those digits included.

Step 3: Match month names

This pattern accepts full and abbreviated English month names. It allows an optional period and an optional comma, then requires whitespace and a four-digit year. Because a four-digit year must come right after the month name, "March 15, 2024" does not match.

\b(Jan(?:uary)?|Feb(?:ruary)?|Mar(?:ch)?|Apr(?:il)?|May|June?|July?|Aug(?:ust)?|Sep(?:t(?:ember)?)?|Oct(?:ober)?|Nov(?:ember)?|Dec(?:ember)?)\.?,?\s+([0-9]{4})\b

One known gap: in day-first text such as "15 March 2024", this pattern still matches "March 2024" and drops the day. If your source uses day-first dates, add a lookbehind that rejects a month name preceded by digits and a space, or review those matches by hand.

Step 4: Normalize matches to YYYY-MM

The Python sketch below runs both patterns, maps each month name to a number using its first three letters, and records every match in its original order. It is an illustrative example: the output shown is what the logic is expected to produce, not a verified run. Run it yourself to confirm.

import re

MONTHS = {"jan": 1, "feb": 2, "mar": 3, "apr": 4, "may": 5, "jun": 6,
          "jul": 7, "aug": 8, "sep": 9, "oct": 10, "nov": 11, "dec": 12}

NUMERIC = re.compile(r"(?<![0-9/.-])(0?[1-9]|1[0-2])[/.-]([0-9]{4})(?![/.-]?[0-9])")
NAMED = re.compile(
    r"\b(Jan(?:uary)?|Feb(?:ruary)?|Mar(?:ch)?|Apr(?:il)?|May|June?|July?"
    r"|Aug(?:ust)?|Sep(?:t(?:ember)?)?|Oct(?:ober)?|Nov(?:ember)?|Dec(?:ember)?)"
    r"\.?,?\s+([0-9]{4})\b"
)

def extract(text):
    found = []
    for m in NUMERIC.finditer(text):
        found.append((m.start(), m.group(0), f"{m.group(2)}-{int(m.group(1)):02d}"))
    for m in NAMED.finditer(text):
        month = MONTHS[m.group(1)[:3].lower()]
        found.append((m.start(), m.group(0), f"{m.group(2)}-{month:02d}"))
    return sorted(found)

text = ("Invoice dated 12/03/2024. Card expires 03/2027. "
        "Report covers March 2024 and Sept. 2025; meeting on March 15, 2024. "
        "Version 1.2024 is unrelated.")

for _, raw, iso in extract(text):
    print(f"{raw!r} -> {iso}")

Expected output, based on the logic rather than an executed run:

'03/2027' -> 2027-03
'March 2024' -> 2024-03
'Sept. 2025' -> 2025-09
'1.2024' -> 2024-01

Two lines in this sample deserve attention. The full dates "12/03/2024" and "March 15, 2024" are correctly skipped. "1.2024" is a version number, but the dot separator lets it through as January 2024. That is the false positive described in Step 1. Drop the dot from the separator class if your text contains decimals or version strings.

Step 5: Watch for look-alike characters

Text copied from documents or web pages may contain characters that look like ordinary separators but are different code points, so the patterns above will not match them. Normalize or include them on purpose:

  • U+00A0 NO-BREAK SPACE between "March" and "2024". \s matches it in Python text patterns and in JavaScript, but some other engines treat it differently.
  • U+2013 EN DASH (–) used in place of a hyphen, as in "03–2027".
  • U+2044 FRACTION SLASH (⁄) or U+2215 DIVISION SLASH (∕) used in place of "/".
  • Full-width digits, such as U+FF10 to U+FF19, in text from East Asian sources.

If you replace these characters before matching, do it on a working copy. They may matter in the original text, for example inside a fraction that should stay a fraction.

Step 6: Verify the results

  • Build a small test file that includes the forms you accept, plus traps: full dates, version numbers, fractions, and the word "may" in a sentence.
  • Compare the number of matches with a manual count on a sample of your real text.
  • Review every match whose normalized month or year looks out of range for your data, such as a year far in the past or future.
  • Keep the original string next to each normalized value so that a reviewer can spot errors without searching the source.
  • Send two-digit years and day-first contexts to manual review instead of converting them silently.

Gaps in this guide

No evidence about a specific extraction tool was supplied, so this guide does not name or compare products, claim compatibility with any application, or report accuracy or speed figures. The patterns cover English month names only. Other languages, other calendars, and spelled-out years such as "March of twenty twenty-four" need their own rules.