Welcome Guest Search | Active Topics | Sign In | Register

DatePicker.SelectedDate gives only Time Options
Loren Dorez
Posted: Wednesday, February 25, 2009 2:41:39 PM
Rank: Advanced Member
Groups: Member

Joined: 1/9/2009
Posts: 97
When i call the DatePicker.SelectedDate is only gives a time of 00:00:00 and should be the default date of 01/01/0001. I used this a few mo nths back and it was giving the selected date as a date not time but now it doesnt is this a known issue?
eo_support
Posted: Wednesday, February 25, 2009 3:01:09 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,194
Hi,

I am not sure if I understand your question correctly. SelectedDate is of DateTime type. So it always gives you both date and time value. So the question is never whether it gives you the date value. The question is whether it gives you the correct date value. You stated "should be the default date of 01/01/0001" further confuses us, what value you are expecting and what value it gives to you? It will be much easier for us to help you if you can state your question more clearly.

Thanks!
Loren Dorez
Posted: Thursday, February 26, 2009 10:41:57 AM
Rank: Advanced Member
Groups: Member

Joined: 1/9/2009
Posts: 97
Hello,

I apologize for the confusion. Let me clarify. If i take a blank page and drop a Datepicker onto the page and choose a style like Windows Vista. And then add a Button to do a post back. ON the button click i check what the datetime is of the BLANK datepiucker and i get "00:00:00" when the date picker says its starting default value is 01/01/0001. Why am i not getting the value of "01/01/0001 00:00:00" when i click the button
Loren Dorez
Posted: Thursday, February 26, 2009 10:53:43 AM
Rank: Advanced Member
Groups: Member

Joined: 1/9/2009
Posts: 97
to clarify a little more. using a unmodified vista datepicker

if i dont type or select a date and do a post back this is whats caputred via the selecteddate property


datepicker1.Selecteddate returns "00:00:00"
AND
datepicker1.selecteddate.tostring("MM/dd/yyyy") return "01/01/0001" as expected

i should not have to force it however to give me a date as the property name is "SelectedDate"
eo_support
Posted: Thursday, February 26, 2009 10:58:21 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,194
Hi,

You might be confused about data value and data displaying format. The value is of DateTime type, which is in binary form and always contain both date and time value. However how it is displayed to you as text is a totally different manner. Just like people can say 6 o'clock or write "6:00", they are the same thing. As far as for DateTime's concern, "01/01/0001" is the same as "01/01/0001 00:00:00" with different displaying format. The same as you can format value "6" as "6" or "6.0000". The difference is displaying format, not the value. The DatePicker gives you the value, it does not format for you. If you want to format it differently, you would do so with string.Format, for example, you can format the same value as "01/01/0001", or format it as "Monday, January 1, 1". How to format it is totally up to you and has nothing to do with DatePicker.

Thanks!
Loren Dorez
Posted: Thursday, February 26, 2009 11:03:08 AM
Rank: Advanced Member
Groups: Member

Joined: 1/9/2009
Posts: 97
Maybe im still botching this let me try again. Sample code below


DatePicker1.SelectedDate RETURNS THIS EXACT VALUE "00:00:00"

This is only a time value where is the Date?
eo_support
Posted: Thursday, February 26, 2009 11:15:28 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,194
Hi,

Please read our previous reply again. We believe we understood your question correctly but it appears that you did not understand our reply.

Thanks!
Loren Dorez
Posted: Thursday, February 26, 2009 11:44:30 AM
Rank: Advanced Member
Groups: Member

Joined: 1/9/2009
Posts: 97
I understand the datepicker doesnt do formatting and thats up to how i want to format it. I understand this but if the property is called "SelectedDate" it shoulw so a DatTime not just time. It should come up with this "01/01/0001 00:00:00" as this would be a true datetime and has nothign to do with formating and this should be the initial value and if people want to format it fomr there then thats fine.

More detail

BLANK DATE PICKER
datepicker1.selectedDate return "00:00:00"

SELECT DATE OF 01/15/1987
Datepcierk1.seleceddate returns " 01/15/1987 00:00:00"

why cant it return "01/01/0001 00:00:00" by default thats what im saying why does it only show a Date and time when i select a date.. I am working around this but just wondering why it only gives a date if you select one otherwise its time value
eo_support
Posted: Thursday, February 26, 2009 12:09:49 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,194
I am not sure how I can explain this more clearly. You keep arguing why SelectedDate returns "00:00:00". This is not a question at all because SelectedDate is a DateTime, while "00:00:00" is a String.

You never see the value of DateTime directly because it's in binary format. In order to see it, you (or Visual Studio debugger or whatever else) always convert it to a String first. It is this conversion that decides whether you see the date part, or see the time part, or see both, or whatever other format.

So to sum it up:

1. DatePicker gives you a DateTime value. You never see this value directly;
2. Visual Studio or your code convert this DateTime value to a String value, this can be implicit and explicit. This String value is what you see;

Step 1 always have both date and time value. Otherwise why would the type call DateTime? Internally date value and time value are always together to represent a specific time point. A date value "without time" has a time component that represents midnight of that date. A time value without date does not exist because it is useless. In another word, we always give you both date and time value.

Step 2 is what decides what you finally see. It has nothing to do with us.

You keep mixing up step 1 and step 2 as a single step.

Hope this clears up.

Thanks!
Loren Dorez
Posted: Thursday, February 26, 2009 1:43:12 PM
Rank: Advanced Member
Groups: Member

Joined: 1/9/2009
Posts: 97
Yes, Thank you i didnt know the Debugger would render it via string and when it does it only shows the time. I get it now the debigger is only showing the time value of the datetime. If i were to put the value of selected date into a datetime variable it would show up 01/01/0001 00:00:00. Sorry if i came across as hard headed or rude. Dont worry your guys support still rocks
eo_support
Posted: Thursday, February 26, 2009 1:47:33 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,194
Glad that you finally see through it. Happy coding! :)


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.