Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
How can I Substract 2 dates and only get the months
for example : (DD/MM/YYYY)
01/01/2010 - 01/01/2009 = 12
01/01/2010 - 01/01/2008 = 24
01/01/2010 - 15/01/2009 = 12
01/02/2010 - 01/06/2009 = 8
Rob Wunderlich wrote:
(year(date2) + month(date2)) - (year(date1) + month(date1)) <div></div>
I guess what Rob tried to do is simplify the formula, and yes indeed it can be simplified as:
=( year(makedate(2008,2,1)) - year(makedate(2006,8,1)) ) *12 + ( month(makedate(2008,2,1)) - month(makedate(2006,8,1)) )
This has some degree of inexactitud, but should work for the next 100 years well.
=12*div((makedate(2010,2,1)-makedate(2009,6,1)),365)
+
floor(mod((makedate(2010,2,1)-makedate(2009,6,1)),365)/28)
Regards.
Hi there, try this:
floor
((monthstart(date#('01/01/2010','DD/MM/YYYY')) - monthstart(date#('15/01/2009','DD/MM/YYYY' ))) /30)
Regards
Hi again, Karl is right about precision, so I realized there's no need to do the calcaulation in terms of days, but only months, hence you can use the following expression, without any fear of loosing precision in any point of the upcoming years:
=( ( year(makedate(2008,2,1)) - year(makedate(2006,8,1)) ) + ( month(makedate(2008,2,1)) - month(makedate(2006,8,1)) ) /12 ) *12
Best Regards
I agree.
(year(date2) + month(date2)) - (year(date1) + month(date1))
Rob Wunderlich wrote:
(year(date2) + month(date2)) - (year(date1) + month(date1)) <div></div>
I guess what Rob tried to do is simplify the formula, and yes indeed it can be simplified as:
=( year(makedate(2008,2,1)) - year(makedate(2006,8,1)) ) *12 + ( month(makedate(2008,2,1)) - month(makedate(2006,8,1)) )
thanks a lot to all the members