Search code examples
asp.net-mvcrazortelerikdatepicker

In Telerik DatePicker, how do I set the minimum date to equal today?


I tried the code below and it didn't work. I assume it's a little more involved.

@Html.Telerik().DatePickerFor(o => o.StartDt).Min(new System.DateTime.Now())

With Francois' suggestion, I get this error: Error


Solution

  • The correct way to get Today/Now is DateTime.Today or DateTime.Now. They aren't constructors, so new System.DateTime.Today() will give you the error you're getting.

    Use:

    @Html.Telerik().DatePickerFor(o => o.StartDt).Min(System.DateTime.Today)

    Also, a good answer on the difference between DateTime.Now and DateTime.Today: Difference between System.DateTime.Now and System.DateTime.Today