ghost21blade ghost21blade - 1 year ago 101 Question

Get date difference in VB.NET

I want to get the difference between two dates chosen by two date time pickers in years, months & days in separate text boxes.

I've tried:

txtyrs.text = datediff(datetimepicker1,datetimepicker2)

It is not working.

Answer Source

Some calculations must be done and then,

dim ts as TimeSpan = dtpicker1.value - dtpicker.value
dim days, months, years as integer
months = 12*(dtp1.value.year - dtp2.value.year) (dtp1.value.month-dtp2.value.month)

... More

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download