DateTimePicker and saving time only..

A

Aaron Smith

How do you get the datetimepicker to save only the time to a databound
field? I have tried format and parse, and the functions work, getting
the cevent.value = "1:25 PM" but it always saves the current date along
with it.. I also have the custom format property set to "hh:mm tt" and
the format and parse have thier formatting set to the same...

Private Sub FormatTime(ByVal sender As Object, ByVal cevent As
ConvertEventArgs)
If Not cevent.DesiredType Is GetType(DateTime) Then
Exit Sub
End If
cevent.Value = CType(cevent.Value,
System.DateTime).ToString("hh:mm tt")
End Sub

Private Sub ParseTime(ByVal sender As Object, ByVal cevent As
ConvertEventArgs)
If Not cevent.DesiredType Is GetType(DateTime) Then
Exit Sub
End If
cevent.Value = CType(cevent.Value,
System.DateTime).ToString("hh:mm tt")
End Sub

Thanks,
Aaron
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top