I need to get difference between two dates and display the result in months and years. This should be simple. As i am very familiar with DateDiff function. That’s what i thought at first. But i don’t know why i spend so much time on this problem. I even had to consult with my friend to discuss about the formula. This is what i got.
strDiffMonth = dateDiff("M","2013-05-12","2015-03-12")
if strDiffMonth < 12 then
strYr = 0
strMth = strDiffMonth
strYr = strDiffMonth / 12
strYrArr = Split(strYr, ".")
strYr = strYrArr(0)
strMth = strDiffMonth Mod 12
frmName.txtYear.value = strYr
frmName.txtMonth.value = strMth
I have to split the year or else it will round up to the nearest integer. There is also solution that i got from googling but haven’t try it out yet. But i think it is worth to try if you have some time. The solution from Praveen that i got from stackoverflow.