i want to add dates from two datetimepicker...for example the user chooses the date 1/1/2012 in the first picker and chooses 1/3/2012 in the second picker the answer should be 3 that will be shown in a textbox..
this is the codes that i tried:

 Dim dt1 As Date = Date.Parse(fromdatepicker.Text)
    Dim dt2 As Date = Date.Parse(todatepicker.Text)

    daysTB.Text = Math.Abs(CInt(dt2.Subtract(dt1).TotalDays))

that code gives me the answer of 2 which is not correct..please help me with this

Recommended Answers

All 2 Replies

The answer will be 2 only since subtracting higher to lower will give the result...if u want all the days inclusive just add 1 to ur result...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.