---
title: diffMonths()
slug: diffmonths
docTags: 
createdAt: 2021-09-14T17:45:26.000Z
---

Returns the total number of months between two given dates.

### Syntax

`diffMonths(date1, date2)`

- `date1` - the date from which counting begins.
- `date2` - the date at which counting ceases.
- **Return type:** [Number](docId\:ucI5tCTfVBhonEJ6ZQijg)&#x20;

### Sample usage

`diffMonths('2021-10-11', '2021-11-11')` returns `1`.

### Supported data types

| **Input type**                                 | **Return type**                         | **Logic**                                                                                     |
| ---------------------------------------------- | --------------------------------------- | --------------------------------------------------------------------------------------------- |
| ****[Date](docId\:xTAQdzvLBTAKjxRnpFwe9)  (x2) | [Number](docId\:ucI5tCTfVBhonEJ6ZQijg)  | The function will count the number of months beginning with `date1`, and ending with `date2`. |
| *Unsupported data types*                       | **[Null](docId\:N9trVqonnBknqL9DrNBP6)  | Unsupported data types return `Null`.                                                         |

