Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Set time in DateTimePicker

Status
Not open for further replies.

jalbao

Programmer
Nov 27, 2000
413
US
I've built a user control that contains two DataTimePicker controls.

The purpose of the user control is to allow the user to select a "start date" and and "end date". These two dates will be used to allow the user to create reports within a datespan.

My problem is, the user simply is selected a date value (i.e. October 5, 2004) - not a time value (i.e. 3:35PM).

I need to set the start date's time to 12:00AM and the end date's time to 11:59PM. The idea being that when a user selects a start date, I need to define the day h/she picked from the 'beginning' of the day, and the end date needs to be defined as the 'end' of the day.

How do I set the time for these DateTimePickers?
 
Do something like this. Paste it in a Form Load() to see it work. Modify it to suit your needs.

Code:
Dim dat As Date = #12/15/2004#
dat = DateAdd(DateInterval.Second, -1, DateAdd(DateInterval.Day, 1, dat))
MsgBox(dat)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top