ShowAll Questionssorted byDate Posted
Mohandaas

# Difference between two date values

When I subtract (End Date - Start Date) the result is a number of days. Is there a formula to get the result in terms of months?

Appreciate your help.

iSqFt_AD

You could divide the result  by 30 or 30.41666 (average days in a month) and use it as a very close estimate. I am sure you could devise a "table" of days in each month that could figure out if the month of the start date is July it has 31 days and the end date is December and has 31 days, but in the end you are converting a number of days into months and the average month has 30.14666 days in it.

SAPOC

You can use the formula Month(End Date)-Month(Start Date).

sfdcfox

SAPOC, your formula is very close, but you forgot to account for years:

```(YEAR(EndDate__c  )*12+MONTH(EndDate__c  ))-
(YEAR(StartDate__c)*12+MONTH(StartDate__c))
```

We convert years into months (i.e. multiply by 12), then add the month to this value. This allows for yearly rollovers, such as Dec 2010-Jan 2011 is one month, not -11 months, and multiple years, such as June 2009-June 2011, which is 24 months, not zero months.

KMK

`StartDate__c.monthsBetween﻿(EndDate__c﻿)`

﻿Try this. It will works fine to find the months differnece between two dates.
If you want Day level difference you use "daysBetween﻿" instead of "monthsBetween﻿﻿"