the time of the date?

IneedaSmoke

Active member
Joined
Mar 4, 2008
Messages
26
Programming Experience
Beginner
I had a question about this as well. I tried using:

monthcalendar.SelectionStart.Date

but it doesn't work the way I want it to. If i select other dates it will give me the correct values. The problem occurs when the user actually wants to use the start date. The start date defaults to todays date and the values i get are 12:00 with no date.

I've tried variable.TodayDate = now, convert.toDateTime and date.Now.ToString but I can't seem to get today's date correct value. Note the same results occur with selectionEnd.Date

Any suggestions?
 
Think i'm gonna go with the Date time picker. It looks like more of what i'm looking for.

Well i'm glad I switched but..... i'm still having the same problem where the date if it's today defaults to 12:00. Still need help
 
Think i'm gonna go with the Date time picker. It looks like more of what i'm looking for.

Well i'm glad I switched but..... i'm still having the same problem where the date if it's today defaults to 12:00. Still need help

What do you need help with?
 
Hrm, not sure where the problem is now. Basically my issue is that if the user does not select a date that is not today, then the value of the control and any variable referencing it becomes '12:00:00 AM'. What I need is the date. Needless to say even if it was referencing today with only time, the time would be incorrect because it's 12:00 and never increments.

I have tried msgbox(today) and it comes out with the correct value; ie. 3/5/2008.

I have also tried :

If dtpDate.Value.ToShortDateString() = "12:00:00 AM" Then
variableDate = Today
Else : variableDate = dtpDate.Value.ToShortDateString()
End If

with variableDate Dim'd as DateTime

Adding the line msgbox(dtpDate.text) returns the value "Wednesday, March 05 2008".

Given this, i'm thinking this might have to do with the type DateTime. Changing the type to string returns ""
 
If you only need the date, don't worry about the time! It is by default 12:00am, that is just how it stores the day in the datetime. You can, of course, set this time if you so desired (but if you are only interested in the date then don't worry about it). When you reference the datetime variable just use .ToShortDateTime().
 
I'm not sure where I can do this. I've changed the properties on the form to short and it's still coming up 12:00:00 AM. It seems like it's saying default but not value. Somehow I think I gotta make it select today when the user doesn't select the date because they want today.
 
Huzzah Happy Panda Dance!

My problem dealt with the Private Sub handling only event changes. I moved the code out of it and it works fine. Thanks for the responses!
 
The Date data type also actually has a Date property that only returns the date part;
VB.NET:
Dim today As Date = Date.Now.Date
A date "without" time give time 00:00:00 in different contexts.

Incidentally the Date data type also have a Today shared property that give the same result as the above example, but the above has a different purpose of course :)
 
Back
Top