There is still a problem with DateTime.Date(datePicker1.DateTicks) converting and showing the wrong date.
Using Erel's suggestion below works fine and allows to step forward thru the dates.
Similar sub to go backward subtracting 1 day at a time.
sub daysForward
daysFwd = daysFwd + 1
Dim p As Period
p.Days = daysFwd
Dim tomorrow As Long = DateUtils.AddPeriod(DateTime.Now, p)
datePicker1.DateTicks = tomorrow
End Sub
In the datePicker1_ValueChanged (Value as Long) sub
displayDate is a string
Sub datePicker1_ValueChanged (Value As Long)
datePicker1.DateFormat ="dd/MM/yyyy"
displayDate = DateTime.Date(datePicker1.DateTicks)
Log("Display date after change = "&displayDate)
End Sub
While stepping backward from today the Log shows:
Display date after change = 04/04/2017
Display date after change = 03/04/2017
Display date after change = 01/04/2017
Yet the datePicker1 shows on the screen the correct dates 04/04/2017, 03/04/2017, 02/04/2017 etc
Once datePicker1 and displayDate get out off step with each other then my database searches are out by 1 day
This is a problem and I can't see a way around it because the only way of checking the difference in the dates is visually....
Any help on this is gratefully appreciated.