cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
m1ch6l
New Member

"Or" operator not working

Hello, newbie here. 😄 In my app I have a date picker field. I would like users to select date that is not greater than today and not older than 6 months.

Currently I have a working formula for the first condition (not greater than today):

If(DataCardValue5.SelectedDate>Today(),Notify( "Selected date cannot be greater than today or older than 6 months", NotificationType.Error ))

 

But I am having troubles adding a second condition for "not older than 6 months". It seems that "Or" operator is not working. Same with "||".

 

What formula should I use so that it includes both conditions?

Thanks

1 ACCEPTED SOLUTION

Accepted Solutions
zmansuri
Super User
Super User

If(DataCardValue5.SelectedDate>Today() || DataCardValue5.SelectedDate< DateAdd(Today(),-6,Months) ,Notify( "Selected date cannot be greater than today or older than 6 months", NotificationType.Error ))

View solution in original post

4 REPLIES 4
zmansuri
Super User
Super User

If(DataCardValue5.SelectedDate>Today() || DataCardValue5.SelectedDate< DateAdd(Today(),-6,Months) ,Notify( "Selected date cannot be greater than today or older than 6 months", NotificationType.Error ))

timl
Super User
Super User

@m1ch6l 

This formula should hopefully work:

 

If(DataCardValue5.SelectedDate >Today() Or
   DataCardValue5.SelectedDate < DateAdd(Today(), -6, Months)
   ,
   Notify( "Selected date cannot be greater than today or older than 6 months",
           NotificationType.Error 
   )
)

 

 

m1ch6l
New Member

@zmansurithank you very much! Works perfectly!

@timlthank you too!

timl
Super User
Super User

You're welcome @m1ch6l - I posted my reply and didn't notice @zmansuri's post. Good luck with the rest of your app!

Helpful resources

Announcements
PA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.

Microsoft Build 768x460.png

Microsoft Build is May 24-26. Have you registered yet?

Come together to explore latest innovations in code and application development—and gain insights from experts from around the world.

May UG Leader Call Carousel 768x460.png

What difference can a User Group make for you?

At the monthly call, connect with other leaders and find out how community makes your experience even better.

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