This is a migrated thread and some comments may be shown as answers.

Comparison of dates using datepicker

4 Answers 148 Views
Calendar, DateTimePicker, TimePicker and Clock
This is a migrated thread and some comments may be shown as answers.
Phuong
Top achievements
Rank 1
Phuong asked on 14 Jan 2008, 09:17 PM
Hi,

I have two date pickers:
FROM and TO. 

I'd like to know if the two dates are further than 3 days apart.  How do I do this comparison? Is there a more efficient way than this?

var date = datePickerFrom.GetDate();
date.setDate(date.getDate() + 3);

var toDate = datePickerTo.GetDate();

if( toDate <= date )
.....

 

Thanks for your help.
PKd

 

4 Answers, 1 is accepted

Sort by
0
Alex Peachey
Top achievements
Rank 1
answered on 15 Jan 2008, 01:50 AM
I don't think there is anything built into the controls themselves but I imagine you could do something like:

if ((datePickerTo.GetDate() - datePickerFrom.GetDate()).Days > 3)
{
...
}
0
Boyko Markov
Telerik team
answered on 15 Jan 2008, 12:00 PM
Hi Phuong,

Thank you for writing.

We don't have this feature built-in RadDateTimePicker for WinForms. Could you please verify you are using RadDateTimePicker for WinForms? The reason I'm asking is that there is no GetDate method there.

The Value property is used to get/set the date/time in RadDateTimePicker. You can use the following code snippet as an example:

if (this.radDateTimePicker1.Value.Day - this.radDateTimePicker2.Value.Day > 3)
{
    // To Do
}

Do not hesitate to write, if you have more questions.

Kind regards,

Boyko Markov
the Telerik team


Instantly find answers to your questions at the new Telerik Support Center
0
Phuong
Top achievements
Rank 1
answered on 15 Jan 2008, 01:37 PM
Thank you for your replies.
In response to Alex's reply, I tried that and it did not work... could be my mistake in a typo or something. 

Boyko,
I am using the RadDatePicker, not RadDateTimePicker.  Is the .value property still available to me then?  If so, then that's very useful.

Thanks,
PKd.


0
Boyko Markov
Telerik team
answered on 16 Jan 2008, 01:03 PM
Hello Phuong,

Could you please give me more information about the control you are using. What would you like to accomplish with it? The Value property is available in RadDateTimePicker. You should use it if you want to get/set the current date in RadDateTimePicker

In our WinForms suite we have a control named RadDateTimePicker, which is closely related to the RadCalendar control. You can find more information about them at: http://www.telerik.com/products/winforms/controls/calendar/overview.aspx.

I'm looking forward to your reply.

Regards,
Boyko Markov
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
Tags
Calendar, DateTimePicker, TimePicker and Clock
Asked by
Phuong
Top achievements
Rank 1
Answers by
Alex Peachey
Top achievements
Rank 1
Boyko Markov
Telerik team
Phuong
Top achievements
Rank 1
Share this question
or