c# - convert number of days into years,months,days -


i want vb.net code convert number of days years,months,days. example: employee experience calculated per date of join(doj) , date of relieve(dor). have doj,dor , number of days worked employee. have calculate how many years , months , days.

output example: doj = 14 feb 2000                 dor = 08 aug 2013 output        : 13 years - 5 months - 25 days 

thanks in advance....

this works me:

var dor = new datetime(2013, 08, 08); var doj = new datetime(2000, 02, 14);  var totalmonths = (dor.year - doj.year) * 12 + dor.month - doj.month; totalmonths += dor.day < doj.day ? -1 : 0;  var years = totalmonths / 12; var months = totalmonths % 12; var days = dor.subtract(doj.addmonths(totalmonths)).days; 

Comments