MONTH function
PRO BASIC
In Jspreadsheet Formulas Pro, the MONTH function is used to retrieve the month from a given date, which is represented by a serial number. This function will provide an integer value corresponding to the month, which ranges from 1 to 12. For instance, if the date is in January, the output will be 1, and if it's in December, the output will be 12. This function is very useful when you need to perform operations based on the month of a specific date.
Documentation
Returns the month of a date represented by a serial number. The month is given as an integer, ranging from 1 (January) to 12 (December).
Category
Date and time
Syntax
MONTH(serial_number)
| Parameter | Description | 
|---|---|
serial_number | 
The date for which you want to determine the month. Jspreadsheet stores dates as sequential serial numbers so they can be used in calculations. | 
Behavior
The MONTH function is used to obtain the month portion of a specific date. This function expects a single argument, which is the date from which the month is to be extracted.
- If the cell is empty, the 
MONTHfunction will return a#VALUE!error. - If the cell contains text that cannot be interpreted as a date, the 
MONTHfunction will return a#VALUE!error. - If the cell contains a boolean, the 
MONTHfunction will treat it as a date starting from December 30, 1899, with TRUE being 1 (December 31, 1899) and FALSE being 0 (December 30, 1899), and return the corresponding month. - If the cell contains an error, the 
MONTHfunction will propagate that error. - The 
MONTHfunction always returns an integer between 1 and 12, inclusive. 
Common Errors
| Error | Description | 
|---|---|
| #VALUE! | The function returns this error when the argument to the MONTH function cannot be interpreted as a date. This includes empty cells and text that does not represent a date. | 
| #NUM! | This error is returned if the supplied date argument is outside Jspreadsheet’s supported date range. | 
| #REF! | This error is returned when the referenced cell is invalid. | 
Best practices
- Always ensure that the argument to the
 MONTHfunction is a valid date or a cell reference to a date.- Be careful when using boolean values as arguments to the
 MONTHfunction. The results may not be what you expect.- To avoid confusion, it is recommended to format the result of the
 MONTHfunction to display as a month name rather than a number.
Usage
A few examples using the MONTH function.
MONTH(DATE(2022,3,15)) // returns 3  
MONTH("2023-05-25") // returns 5  
MONTH(TODAY()) // returns the current month number  
MONTH(A1) // if A1 contains 2023-12-10, returns 12  
Interactive Spreadsheet Demo
<html>
<script src="https://jspreadsheet.com/v11/jspreadsheet.js"></script>
<script src="https://jsuites.net/v5/jsuites.js"></script>
<link rel="stylesheet" href="https://jsuites.net/v5/jsuites.css" type="text/css" />
<link rel="stylesheet" href="https://jspreadsheet.com/v11/jspreadsheet.css" type="text/css" />
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Material+Icons" />
<script src="https://cdn.jsdelivr.net/npm/@jspreadsheet/formula-pro/dist/index.min.js"></script>
<div id="spreadsheet"></div>
<script>
// Set your JSS license key (The following key only works for one day)
jspreadsheet.setLicense('MmEwN2UyMGFhMWFmOTcxNWQ4NmNiMzc3MWMzN2IyYjg5OTJlZjJlNDkzOTgzYzBlNjVmZGZiYjkzMTQ5MWU3NjYzODJjMjFkZjZjZjUxZGFiZTZmNTIzMWQ2OGQxMzY5OTExNGI0Zjk0NWRjNWY2ODYzNWU3NTUyMjc3Yjg1MDIsZXlKamJHbGxiblJKWkNJNklpSXNJbTVoYldVaU9pSktjM0J5WldGa2MyaGxaWFFpTENKa1lYUmxJam94TnpZeU16QTJNRGd3TENKa2IyMWhhVzRpT2xzaWFuTndjbVZoWkhOb1pXVjBMbU52YlNJc0ltTnZaR1Z6WVc1a1ltOTRMbWx2SWl3aWFuTm9aV3hzTG01bGRDSXNJbU56WWk1aGNIQWlMQ0p6ZEdGamEySnNhWFI2TG1sdklpd2lkMlZpWTI5dWRHRnBibVZ5TG1sdklpd2liRzlqWVd4b2IzTjBJbDBzSW5Cc1lXNGlPaUl6TkNJc0luTmpiM0JsSWpwYkluWTNJaXdpZGpnaUxDSjJPU0lzSW5ZeE1DSXNJbll4TVNJc0ltTm9ZWEowY3lJc0ltWnZjbTF6SWl3aVptOXliWFZzWVNJc0luQmhjbk5sY2lJc0luSmxibVJsY2lJc0ltTnZiVzFsYm5Seklpd2lhVzF3YjNKMFpYSWlMQ0ppWVhJaUxDSjJZV3hwWkdGMGFXOXVjeUlzSW5ObFlYSmphQ0lzSW5CeWFXNTBJaXdpYzJobFpYUnpJaXdpWTJ4cFpXNTBJaXdpYzJWeWRtVnlJaXdpYzJoaGNHVnpJaXdpWm05eWJXRjBJbDBzSW1SbGJXOGlPblJ5ZFdWOQ==');
// Set the extensions
jspreadsheet.setExtensions({ formula });
// Create a new spreadsheet
jspreadsheet(document.getElementById('spreadsheet'), {
  worksheets: [{
    data: [
    [
        "Date",
        "Month"
    ],
    [
        "2023-01-15",
        "=MONTH(A2)"
    ],
    [
        "2023-06-22",
        "=MONTH(A3)"
    ],
    [
        "2023-12-05",
        "=MONTH(A4)"
    ]
]
  }]
});
</script>
</html>
import React, { useRef } from "react";
import { Spreadsheet, Worksheet, jspreadsheet } from "@jspreadsheet/react";
import formula from "@jspreadsheet/formula-pro";
import "jsuites/dist/jsuites.css";
import "jspreadsheet/dist/jspreadsheet.css";
// Set license
jspreadsheet.setLicense('MmEwN2UyMGFhMWFmOTcxNWQ4NmNiMzc3MWMzN2IyYjg5OTJlZjJlNDkzOTgzYzBlNjVmZGZiYjkzMTQ5MWU3NjYzODJjMjFkZjZjZjUxZGFiZTZmNTIzMWQ2OGQxMzY5OTExNGI0Zjk0NWRjNWY2ODYzNWU3NTUyMjc3Yjg1MDIsZXlKamJHbGxiblJKWkNJNklpSXNJbTVoYldVaU9pSktjM0J5WldGa2MyaGxaWFFpTENKa1lYUmxJam94TnpZeU16QTJNRGd3TENKa2IyMWhhVzRpT2xzaWFuTndjbVZoWkhOb1pXVjBMbU52YlNJc0ltTnZaR1Z6WVc1a1ltOTRMbWx2SWl3aWFuTm9aV3hzTG01bGRDSXNJbU56WWk1aGNIQWlMQ0p6ZEdGamEySnNhWFI2TG1sdklpd2lkMlZpWTI5dWRHRnBibVZ5TG1sdklpd2liRzlqWVd4b2IzTjBJbDBzSW5Cc1lXNGlPaUl6TkNJc0luTmpiM0JsSWpwYkluWTNJaXdpZGpnaUxDSjJPU0lzSW5ZeE1DSXNJbll4TVNJc0ltTm9ZWEowY3lJc0ltWnZjbTF6SWl3aVptOXliWFZzWVNJc0luQmhjbk5sY2lJc0luSmxibVJsY2lJc0ltTnZiVzFsYm5Seklpd2lhVzF3YjNKMFpYSWlMQ0ppWVhJaUxDSjJZV3hwWkdGMGFXOXVjeUlzSW5ObFlYSmphQ0lzSW5CeWFXNTBJaXdpYzJobFpYUnpJaXdpWTJ4cFpXNTBJaXdpYzJWeWRtVnlJaXdpYzJoaGNHVnpJaXdpWm05eWJXRjBJbDBzSW1SbGJXOGlPblJ5ZFdWOQ==');
// Set the extensions
jspreadsheet.setExtensions({ formula });
export default function App() {
    // Spreadsheet array of worksheets
    const spreadsheet = useRef();
    // Worksheet data
    const data = [
    [
        "Date",
        "Month"
    ],
    [
        "2023-01-15",
        "=MONTH(A2)"
    ],
    [
        "2023-06-22",
        "=MONTH(A3)"
    ],
    [
        "2023-12-05",
        "=MONTH(A4)"
    ]
];
    // Render component
    return (
        <Spreadsheet ref={spreadsheet}>
            <Worksheet data={data} />
        </Spreadsheet>
    );
}
<template>
    <Spreadsheet ref="spreadsheet">
        <Worksheet :data="data" />
    </Spreadsheet>
</template>
<script>
import { Spreadsheet, Worksheet, jspreadsheet } from "@jspreadsheet/vue";
import "jsuites/dist/jsuites.css";
import "jspreadsheet/dist/jspreadsheet.css";
import formula from "@jspreadsheet/formula-pro";
// Set license
jspreadsheet.setLicense('MmEwN2UyMGFhMWFmOTcxNWQ4NmNiMzc3MWMzN2IyYjg5OTJlZjJlNDkzOTgzYzBlNjVmZGZiYjkzMTQ5MWU3NjYzODJjMjFkZjZjZjUxZGFiZTZmNTIzMWQ2OGQxMzY5OTExNGI0Zjk0NWRjNWY2ODYzNWU3NTUyMjc3Yjg1MDIsZXlKamJHbGxiblJKWkNJNklpSXNJbTVoYldVaU9pSktjM0J5WldGa2MyaGxaWFFpTENKa1lYUmxJam94TnpZeU16QTJNRGd3TENKa2IyMWhhVzRpT2xzaWFuTndjbVZoWkhOb1pXVjBMbU52YlNJc0ltTnZaR1Z6WVc1a1ltOTRMbWx2SWl3aWFuTm9aV3hzTG01bGRDSXNJbU56WWk1aGNIQWlMQ0p6ZEdGamEySnNhWFI2TG1sdklpd2lkMlZpWTI5dWRHRnBibVZ5TG1sdklpd2liRzlqWVd4b2IzTjBJbDBzSW5Cc1lXNGlPaUl6TkNJc0luTmpiM0JsSWpwYkluWTNJaXdpZGpnaUxDSjJPU0lzSW5ZeE1DSXNJbll4TVNJc0ltTm9ZWEowY3lJc0ltWnZjbTF6SWl3aVptOXliWFZzWVNJc0luQmhjbk5sY2lJc0luSmxibVJsY2lJc0ltTnZiVzFsYm5Seklpd2lhVzF3YjNKMFpYSWlMQ0ppWVhJaUxDSjJZV3hwWkdGMGFXOXVjeUlzSW5ObFlYSmphQ0lzSW5CeWFXNTBJaXdpYzJobFpYUnpJaXdpWTJ4cFpXNTBJaXdpYzJWeWRtVnlJaXdpYzJoaGNHVnpJaXdpWm05eWJXRjBJbDBzSW1SbGJXOGlPblJ5ZFdWOQ==');
// Set the extensions
jspreadsheet.setExtensions({ formula });
export default {
    components: {
        Spreadsheet,
        Worksheet,
    },
    data() {
        // Worksheet data
        const data = [
    [
        "Date",
        "Month"
    ],
    [
        "2023-01-15",
        "=MONTH(A2)"
    ],
    [
        "2023-06-22",
        "=MONTH(A3)"
    ],
    [
        "2023-12-05",
        "=MONTH(A4)"
    ]
]
        return {
            data
        };
    }
}
</script>
import { Component, ViewChild, ElementRef } from "@angular/core";
import jspreadsheet from "jspreadsheet";
import * as formula from "@jspreadsheet/formula-pro";
// Set your JSS license key (The following key only works for one day)
jspreadsheet.setLicense('MmEwN2UyMGFhMWFmOTcxNWQ4NmNiMzc3MWMzN2IyYjg5OTJlZjJlNDkzOTgzYzBlNjVmZGZiYjkzMTQ5MWU3NjYzODJjMjFkZjZjZjUxZGFiZTZmNTIzMWQ2OGQxMzY5OTExNGI0Zjk0NWRjNWY2ODYzNWU3NTUyMjc3Yjg1MDIsZXlKamJHbGxiblJKWkNJNklpSXNJbTVoYldVaU9pSktjM0J5WldGa2MyaGxaWFFpTENKa1lYUmxJam94TnpZeU16QTJNRGd3TENKa2IyMWhhVzRpT2xzaWFuTndjbVZoWkhOb1pXVjBMbU52YlNJc0ltTnZaR1Z6WVc1a1ltOTRMbWx2SWl3aWFuTm9aV3hzTG01bGRDSXNJbU56WWk1aGNIQWlMQ0p6ZEdGamEySnNhWFI2TG1sdklpd2lkMlZpWTI5dWRHRnBibVZ5TG1sdklpd2liRzlqWVd4b2IzTjBJbDBzSW5Cc1lXNGlPaUl6TkNJc0luTmpiM0JsSWpwYkluWTNJaXdpZGpnaUxDSjJPU0lzSW5ZeE1DSXNJbll4TVNJc0ltTm9ZWEowY3lJc0ltWnZjbTF6SWl3aVptOXliWFZzWVNJc0luQmhjbk5sY2lJc0luSmxibVJsY2lJc0ltTnZiVzFsYm5Seklpd2lhVzF3YjNKMFpYSWlMQ0ppWVhJaUxDSjJZV3hwWkdGMGFXOXVjeUlzSW5ObFlYSmphQ0lzSW5CeWFXNTBJaXdpYzJobFpYUnpJaXdpWTJ4cFpXNTBJaXdpYzJWeWRtVnlJaXdpYzJoaGNHVnpJaXdpWm05eWJXRjBJbDBzSW1SbGJXOGlPblJ5ZFdWOQ==');
// Set the extensions
jspreadsheet.setExtensions({ formula });
@Component({
    standalone: true,
    selector: "app-root",
    template: `<div #spreadsheet></div>`
})
export class AppComponent {
    @ViewChild("spreadsheet") spreadsheet: ElementRef;
    // Worksheets
    worksheets: jspreadsheet.worksheetInstance[];
    // Create a new data grid
    ngAfterViewInit() {
        // Create spreadsheet
        this.worksheets = jspreadsheet(this.spreadsheet.nativeElement, {
            worksheets: [{
                data: [
    [
        "Date",
        "Month"
    ],
    [
        "2023-01-15",
        "=MONTH(A2)"
    ],
    [
        "2023-06-22",
        "=MONTH(A3)"
    ],
    [
        "2023-12-05",
        "=MONTH(A4)"
    ]
]
            }]
        });
    }
}