Placing Time from DateTimePicker in variable?

I there a way to place the time part from a selected DateTimePicker DateTimeValue in a string variable so I can use it in this code?

Var theTime As String = DesktopDateTimePicker.DisplayModes.TimeOnly
MessageBox(theTime)
if theTime > 00:00 and theTime < 08:59 then
'WinStoryCalendarEvents.PopDayParts.SelectedRowIndex = 0
end if

DateTime has properties for Hour and Minute. Use ToString("00") to format them and combine them in the string you want.

I don’t see hour, minute or DateTime properties for the DateTimePicker, how is DateTime related to the DateTimePicker?

DateTimePicker.SelectedDate is a DateTime. Ie., DateTimePicker returns a DateTime.

Try

var d as DateTime = DesktopDateTimePicker1.SelectedDate
var hr as string = d.Hour.ToString("00")
var mn as string = d.Time.ToString("00")
var theTime as string = hr + ":" + mn
MessageBox(theTime)
1 Like

Thanks, Tim!