Date time change time to midnight

Easy one here user gives a date time through the date time picker, instead of the time picked i want the date to set to midnight.  vb.net
MillkindAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

CodeCruiserCommented:
Set it to 00:00

Dim dt as DateTime = datetime.parse(selecteddate & " 00:00")
0
MillkindAuthor Commented:
not a valid date time is the error.

selected date time comes in with a time already on it.  So we have to change the time it came with to midnight.
0
CodeCruiserCommented:
Try either

Dim dt As DateTime = selectedDate.AddMinutes((24*60) - SelectedDate.TimeOfDay))

or use ParseExact

http://msdn.microsoft.com/en-us/library/w2sa9yss.aspx
0
Mike TomlinsonMiddle School Assistant TeacherCommented:
Just use the Date() property of the DateTime instance as it returns the Date portion with the Time portion set to midnight...
http://msdn.microsoft.com/en-us/library/system.datetime.date.aspx

    "A new object with the same date as this instance, and the time value set to 12:00:00 midnight (00:00:00)"

Example:

    someDateTime = someDateTime.Date
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
MillkindAuthor Commented:
Perfect
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.