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.
Try this:
Dim date1 As Date = Date.Now
Dim date2 As Date = date1.AddDays(4.0#)
Dim span = date2 - date1
Dim days As Double = span.TotalDays '=4
And if you want to extract the years, take a look at this post.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With