Hi Rick,
Nice function you wrote.
You challenged me to do so too.
Wouldn't this suffice ?
Code:Function snb(x0 as string, x1 as string) x2 = DateDiff("m", x0, x1) - IIf(Day(x0) > Day(x1), 1, 0) c01 = x2 \ 12 c02 = x2 Mod 12 c03 = Day(x1) - Day(x0) + IIf(Day(x1) >= Day(x0), 0, Day(CDate(x1) - Day(x1))) snb = c01 & " year" & IIf(c01 = 1, ", ", "s, ") & c02 & " month" & IIf(c02 = 1, ", ", "s, ") & c03 & " day" & IIf(c03 = 1, "", "s") End FunctionCode:sub tst() msgbox snb("02-04-2011","22-02-2012") end sub




Reply With Quote
Bookmarks