Kyle
Kyle

Reputation: 5547

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

Upvotes: 0

Views: 1151

Answers (2)

Francois
Francois

Reputation: 10968

Use Today() instead of Now().

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

EDIT: of course, no need for NEW here :)

Upvotes: 1

Gromer
Gromer

Reputation: 9931

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

Upvotes: 1

Related Questions