How to Use the MONTH Function in Google Sheets QUERY

Published on

This article is a child post of the hub Date Logic in QUERY Function in Google Sheets. It explains how to use the MONTH function in Google Sheets QUERY, including how it differs from the worksheet MONTH function and how to use it for month-wise summaries.

What Is the MONTH Function in Google Sheets QUERY?

The MONTH function is a scalar function in Google Sheets QUERY. It returns a month number from a date or DateTime (timestamp) column.

Key characteristics

  • It is a scalar function, so it returns one value per row (unlike aggregate functions, which return one value per group).
  • When you wrap a column with MONTH(), QUERY changes the column label automatically.
    • For example, if column C is labeled Purchase Date, the output label becomes:month(Purchase Date)

Basic syntax example

=QUERY(C1:C, "select month(C)", 1)

MONTH Function in QUERY vs Worksheet MONTH Function

Although both functions extract month numbers, they behave differently.

Important difference

  • QUERY MONTH function → returns zero-based month numbers
    • January = 0
    • February = 1
    • December = 11
  • Worksheet MONTH() function → returns 1–12
    • January = 1
    • February = 2
    • December = 12

You May Like: Google Sheets: The Complete Guide to All Date Functions

This difference often surprises users and is a common source of errors.

Later in this tutorial, you’ll learn how to convert zero-based months into normal month numbers.

This tutorial is part of the Date Logic in QUERY hub, which covers date criteria, month-based filtering, and DateTime handling in Google Sheets QUERY.

Purpose of the MONTH Function in Google Sheets QUERY

The MONTH function in QUERY is mainly used for two purposes:

  1. Return month numbers from a date or DateTime column
  2. Group and summarize data by month

Sample Data Structure

Assume the following columns:

  • Column A – Date
  • Column B – Product
  • Column C – Salesperson
  • Column D – Quantity
  • Column E – Rate
  • Column F – Amount
Sample data used for the MONTH function in Google Sheets QUERY

Return Month Numbers from a Date Column

To extract month numbers from the dates in column A, use:

=QUERY(A1:A, "select month(A)",1)

Insert this formula in the top row of any empty column.

month(Date)
0
0
0
1
2
2

Note: The returned month numbers are zero-based.

Group Data by Month Using QUERY

Now let’s see how to summarize data month-wise using the MONTH function.

Goal

Create a report that shows the total sales amount per product for each month.

For this example, we’ll use only three columns:

  • Column A – Date
  • Column B – Product
  • Column F – Amount

Example: Month-Wise Summary Using MONTH Function

=QUERY(A1:F,
 "select month(A), B, sum(F)
  where A is not null
  group by month(A), B",
  1)

What this formula does

  • month(A) converts dates into zero-based month numbers
  • group by month(A), B groups the data by month and product
  • sum(F) aggregates the Amount column
month(Date)Productsum Amount
0Coverall150
0Illuminated Jacket30
1Illuminated Jacket4380
2Coverall162

The result shows:

  • Month number (0–11)
  • Product name
  • Total amount for each product in each month

Related: What Is the Correct Clause Order in Google Sheets QUERY?

How to Convert Zero-Based Month Numbers

Since QUERY returns months as 0–11, you may want standard month numbers (1–12).

You can do this by adding +1 to the MONTH function.

=QUERY(A1:F,
 "select month(A)+1, B, sum(F)
  where A is not null
  group by month(A)+1, B",
  1)

Why this works

  • QUERY counts months starting from 0
  • Adding +1 converts them to the usual month numbering

This produces a cleaner and more familiar month-wise summary.

sum(month(Date)1())Productsum Amount
1Coverall150
1Illuminated Jacket30
2Illuminated Jacket4380
3Coverall162

Key Takeaways

  • The MONTH function in Google Sheets QUERY is a scalar function.
  • It returns zero-based month numbers (0–11).
  • It is commonly used for month-wise grouping and summarization.
  • Add +1 to convert zero-based months into standard month numbers.

That’s how to use the MONTH function in Google Sheets QUERY to extract and summarize data by month.

Thanks for reading, and enjoy exploring date logic in QUERY!

Prashanth KV
Prashanth KV
Your Trusted Google Sheets and Excel Expert Prashanth KV is a Diamond Product Expert in Google Sheets, officially recognized by Google for his contributions to the Docs Editors Help Community and featured in the Google Product Experts Directory. Explore his blog to learn advanced formulas, automation tips, and problem-solving techniques to elevate your spreadsheet skills.

Top Discussions

More like this

Free Monthly Expense Tracker Template in Google Sheets (Dashboard Included)

Watch the quick walkthrough below to see how to use this Free Monthly Expense...

The Complete Guide to XLOOKUP in Google Sheets (15+ Practical Examples)

The XLOOKUP function largely replaces traditional lookup functions such as LOOKUP, VLOOKUP, and HLOOKUP...

How to Sort and Filter Pivot Tables in Google Sheets (Complete Guide)

Sorting and filtering are two of the most important techniques for analyzing data in...

2 COMMENTS

    • Hi, Arvind Pradhan,

      I’ve already explained the same within this tutorial.

      It’s numbered 0-11. To get 1-12, you should add 1 to the returned month numbers.

      Eg.

      Use Month(A)+1 instead of Month(A).

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.