7
Vote

DatePicker MinDate and MaxDate request

description

I would like to set a min and max date on the DatePicker control.

comments

dbachrach wrote Jul 8, 2011 at 4:17 PM

Anyone who is interested in this feature, can you explain your use case? Are you using this feature for Todo lists, reminders, agendas, or anything else? What's are the typical constraints? Setting either min or max, or setting both? What are the typical size of ranges you expect between min and max?

Thanks

jeremypippen2007 wrote Jul 8, 2011 at 5:10 PM

This was for a time entry system at work. We enter our time in week by week. The functionality on our website displays only one week at a time, and when you enter time, our date picker only shows the current week. We wanted to keep it the same if possible on our WP7 app.

klange wrote Jul 6, 2012 at 3:41 PM

I am interested in this feature. My most common use case is that the user must enter a Date Of Birth for a record keeping system. I want to limit the data entry to a value that is possible for a living person. (Say 1/1/1850 - Now).

Also, I am usually storing the entered date in an SQL database where the datetime has a different range than the .Net DateTime. Currently, the date picker allows the user to enter a date such as 1/1/1111 that doesn't fit in SQL so I get an ugly exception down at the database layer.

So, currently, my solution is to use "Validation". But it would be cleaner to me if the user couldn't enter bad dates in the first place.

(For other people struggling with this issue, check out System.ComponentModel.DataAnnotations.RangeAttribute)

[Range(typeof(DateTime), "1/1/1900", "12/31/2099", ErrorMessage = "Value for {0} must be between {1} and {2}")]

Thanks.

Bevan wrote Aug 10, 2012 at 4:19 AM

I think this would be a great addition to the control.

you asked for an example so in my case I have an app that is tracking task data.
One of the fields is the date the task was actually completed. Obviously it should not be possible to set any date in the future as this could only be a guess at best and not an actual date of completion.
In my case I would like to be able to set a MaxDate property (in my current scenario this would be DateTime.now). It would also be useful to be able to provide a string that could be displayed in the control explaining the date constraint rule to the user to avoid frustration.