cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Dushy
Frequent Visitor

How do I make sure the user enters an end date that is greater than or equal to the start date, not before?

How do I make sure the user enters an end date that is greater than the start date, not before?

3 ACCEPTED SOLUTIONS

Accepted Solutions
mdevaney
Super User III
Super User III

@Dushy 

Use this code in the DisplayMode property of your form's submit button to disable it when the date selected is invalid.

 

If(DatePicker_StartDate.SelectedDate > DatePicker_EndDate.SelectedDate, DisplayMode.Edit, DisplayMode.Disabled)

 

---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

View solution in original post

eka24
Super User III
Super User III

You can notify the user when the end date is selected. So in the Onselect property of the end date picker;

If(StartDate.SelectedDate>EndDate.SelectedDate, Notify ("Endate Should be equal or greater than start date",Error))

 

You can also place the formula on a Button instead of the Date picker so that the user can't save the form untill the right date is selected.

------------

If you like this post, give a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users find it.

View solution in original post

v-albai-msft
Microsoft
Microsoft

Hi @Dushy,

There are many ways to achieve your purpose, depends on which way you prefer.

1. If you want to disable users to enter a date that is not allowed, you can limit the submit button--- use the solution provided by @mdevaney  or the solution provided by @eka24 .

2. If you just want to have a reminder to tell users that the entered end date is less than start date, you can add a label under the End Date, set the Text property of label to “Note: Your EndDate is less than StartDate”, and set the Visible property to below:

If(DatePicker_End>=DatePicker_Start, false,true)​

This time, if end date is less than start date, the label will display to remind users.

v-albai-msft_0-1611729707443.png

v-albai-msft_1-1611729707446.png

3. If you want to review all the records in a gallery, and want to directly see if EndDate is greater than StartDate, you can add a label and set its Text property to:

DateDiff(ThisItem.StartDate,ThisItem.EndDate)​

 

This time, you can directly see the the difference between EndDate and StartDate(if the number is greater than 0, it means the EndDate is greater than StartDate):

v-albai-msft_2-1611729707449.png

Best Regards,

Allen

View solution in original post

3 REPLIES 3
mdevaney
Super User III
Super User III

@Dushy 

Use this code in the DisplayMode property of your form's submit button to disable it when the date selected is invalid.

 

If(DatePicker_StartDate.SelectedDate > DatePicker_EndDate.SelectedDate, DisplayMode.Edit, DisplayMode.Disabled)

 

---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

View solution in original post

eka24
Super User III
Super User III

You can notify the user when the end date is selected. So in the Onselect property of the end date picker;

If(StartDate.SelectedDate>EndDate.SelectedDate, Notify ("Endate Should be equal or greater than start date",Error))

 

You can also place the formula on a Button instead of the Date picker so that the user can't save the form untill the right date is selected.

------------

If you like this post, give a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users find it.

View solution in original post

v-albai-msft
Microsoft
Microsoft

Hi @Dushy,

There are many ways to achieve your purpose, depends on which way you prefer.

1. If you want to disable users to enter a date that is not allowed, you can limit the submit button--- use the solution provided by @mdevaney  or the solution provided by @eka24 .

2. If you just want to have a reminder to tell users that the entered end date is less than start date, you can add a label under the End Date, set the Text property of label to “Note: Your EndDate is less than StartDate”, and set the Visible property to below:

If(DatePicker_End>=DatePicker_Start, false,true)​

This time, if end date is less than start date, the label will display to remind users.

v-albai-msft_0-1611729707443.png

v-albai-msft_1-1611729707446.png

3. If you want to review all the records in a gallery, and want to directly see if EndDate is greater than StartDate, you can add a label and set its Text property to:

DateDiff(ThisItem.StartDate,ThisItem.EndDate)​

 

This time, you can directly see the the difference between EndDate and StartDate(if the number is greater than 0, it means the EndDate is greater than StartDate):

v-albai-msft_2-1611729707449.png

Best Regards,

Allen

View solution in original post

Helpful resources

Announcements
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

MBAS Attendee Badge

Claim Your Badge & Digital Swag!

Check out how to claim yours today!

secondImage

Are Your Ready?

Test your skills now with the Cloud Skill Challenge.

Top Solution Authors
Top Kudoed Authors
Users online (58,007)