---
schema_version: "1"
id: 2943c9b7893831808007f327c95343360ff1763ebf2f794c4b59f045a3727750
title: months_to
collection: admin
version: current
locale: en-us
portal_url: https://docs.salesforce.com/admin/current/en-us/sales/264-0-0/spiff_function_ref_months_to.md
canonical_url: https://help.salesforce.com/s/articleView?id=sales.spiff_function_ref_months_to.htm&release=264.0.0&type=5
source_site: help.salesforce.com
content_type: documentation
content_hash: 7fbc1f359d745edc7bb6d3aa919724b34ab1a07341125881738e880c6fd6bbbb
description: Returns the number of months between two dates or times in Salesforce Spiff. If the return value is a negative number, the second date occurred before the first date.
products:
  - Sales Cloud
  - Sales Enablement
release: "264"
---
# months\_to

Returns the number of months between two dates or times in Salesforce Spiff. If the return value is a negative number, the second date occurred before the first date.

### Required Editions

<table class="slds-table slds-table_bordered slds-max-medium-table_stacked slds-m-bottom_small edition"><colgroup><col></colgroup><tbody><tr class=""><td class="slds-cell-wrap" style="vertical-align:top;">Available in: both Salesforce Classic (not available in all orgs) and Lightning Experience</td></tr><tr class=""><td class="slds-cell-wrap" style="vertical-align:top;">Available in: <strong>Enterprise</strong>, <strong>Unlimited</strong>, and <strong>Developer</strong> Editions</td></tr><tr class=""><td class="slds-cell-wrap" style="vertical-align:top;">Available for an additional cost in: <strong>Professional</strong> Edition with Web Services API Enabled</td></tr></tbody></table>

## Syntax

```
months_to(start_date_or_time, end_date_or_time)
```

## Arguments

  
| Argument | Required? | Description |
| --- | --- | --- |
| start\_date\_or\_time | Required | The Date or Date & Time value that's the lower bound of the range. This argument supports any date functions. |
| end\_date\_or\_time | Required | The Date or Date & Time value that's the upper bound of the range. This argument supports any date functions. |

## Example

Create a custom field on the account object that represents the contract start date, and return the number of months between the contract start date and the deal's close date.

```
=months_to(DealToAccount.ContractStartDate__c, CloseDate)
```

Your company awards a $100 bonus to a rep whose go-live date occurs within two months of closing the deal. Return the months between the go-live date and close date. Wrap the function with an `if` statement that determines whether the result is less than two months and, if so, rewards $100 to the rep for each deal.

```
=if(months_to(CloseDate, GoLiveDate) <= 2, 100, 0)
```

Return the number of a specific month within a quarter, such as `3` for March.

```
=months_to(beginning_of_quarter(statement_period.start_date), statement_period.start_date) + 1
```

#### See Also

- [beginning\_of\_quarter](https://help.salesforce.com/s/articleView?id=sales.spiff_function_ref_beginning_of_quarter.htm&release=264.0.0&type=5 "Returns the first day of the quarter for a specific date or time value in Salesforce Spiff. The return format is YYYY-MM-DD. If you've specified fiscal year dates that are different from standard calendar dates, use the beginning_of_fiscal_quarter() function instead.")