Comparison of dates using datepicker

5 posts, 0 answers
  1. Phuong
    Phuong avatar
    13 posts
    Member since:
    Nov 2007

    Posted 14 Jan 2008 Link to this post

    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

     

  2. Alex Peachey
    Alex Peachey avatar
    56 posts
    Member since:
    May 2006

    Posted 14 Jan 2008 Link to this post

    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)
    {
    ...
    }
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Boyko Markov
    Admin
    Boyko Markov avatar
    610 posts

    Posted 15 Jan 2008 Link to this post

    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
  5. Phuong
    Phuong avatar
    13 posts
    Member since:
    Nov 2007

    Posted 15 Jan 2008 Link to this post

    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.


  6. Boyko Markov
    Admin
    Boyko Markov avatar
    610 posts

    Posted 16 Jan 2008 Link to this post

    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
Back to Top
UI for WinForms is Visual Studio 2017 Ready