Mallikarjuna Rao
Mallikarjuna Rao

Reputation: 211

How to set "n" years back date from present date in kendo datepicker?

I want to set 10 years back date from today date in kendo datepicker.

Upvotes: 1

Views: 1271

Answers (2)

Mahendra Onteru
Mahendra Onteru

Reputation: 124

For an example: When we are working with any Bank form applications, the applicant should have minimum 20 years from Today's Date to apply a particular Exam.

So It's Better to give Max-Date as the Day 20 years from Today's Date It is very easy to set past 'n' number of years date from today date in kendo datepicker.

Find the small snippet below.

var toDate = new Date();

// Here 'n' Excludes number of years from today's Date.

var pastDate= new Date(toDate.setFullYear(toDate.getFullYear()- n));

$("#birthDayDate").kendoDatePicker({ max: pastDate });

Upvotes: 1

Satya Ranjan Sahoo
Satya Ranjan Sahoo

Reputation: 1086

If you want to initialize your date picker with 10 years back date always, then in your HTML it would be something like this:

    @(Html.Kendo().DatePicker().Name("myDatePicker").Value(DateTime.Today.AddYears(-10)))

Upvotes: 2

Related Questions