cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Helper II
Helper II

Date - OnChange/OnSelect formula is not working

Hello,

 

I am looking for the formula for date picker, that only accepts dates from current and next month, therefore I have applied following formula, however it's not working as expected - Can any one please suggest What am I missing??

 

DatePicker OnSelect/OnChange

If(Month(DataCardValue9.SelectedDate) <> Month(Today())+1 Or Month(DataCardValue9.SelectedDate) <> Month(Today()),Set(ErrMessage,"Invalid Date"),Set(ErrMessage,""))

 

Label.Text = ErrMessage

 

Can you please share correct formula?

 

Thanks,

1 ACCEPTED SOLUTION

Accepted Solutions

Hi @PowerApper25 ,

Very strange, should work but does not - however this does

If(
   Month(DataCardValue9.SelectedDate) 
   = 
   Month(Today())+1 
   ||
   Month(DataCardValue9.SelectedDate) 
   = 
   Month(Today())
   ,
   Set(ErrMessage,"")
   ,
   Set(ErrMessage,"Invalid Date")
)

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

View solution in original post

4 REPLIES 4
Super User III
Super User III

Hi @PowerApper25 ,

Try the below - I parsed it for easy reference of the logic.

 

If(
   Month(DataCardValue9.SelectedDate) 
   <> 
   Month(Today())+1 
   ||
   Month(DataCardValue9.SelectedDate) 
   <> 
   Month(Today())
   ,
   Set(ErrMessage,"Invalid Date")
   ,
   Set(ErrMessage,"")
)

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up..

 

Hi WarrenBelz,

 

Thank you for your suggestion, however it still behaves the same, Error message is not disappearing if condition is right, Does this formula work for you?

 

Best Regards,

Hi @PowerApper25 ,

Very strange, should work but does not - however this does

If(
   Month(DataCardValue9.SelectedDate) 
   = 
   Month(Today())+1 
   ||
   Month(DataCardValue9.SelectedDate) 
   = 
   Month(Today())
   ,
   Set(ErrMessage,"")
   ,
   Set(ErrMessage,"Invalid Date")
)

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

View solution in original post

Thank you very much WarrenBelz 🙂 That worked like a charm!

Helpful resources

Announcements
New Badges

New Solution Badges!

Check out our new profile badges recognizing authored solutions!

New Power Super Users

Congratulations!

We are excited to announce the Power Apps Super Users!

Power Apps Community Call

Power Apps Community Call: February

Did you miss the call? Check out the Power Apps Community Call here.

Microsoft Ignite

Microsoft Ignite

Join digitally, March 2–4, 2021 to explore new tech that's ready to implement. Experience the keynote in mixed reality through AltspaceVR!

Top Solution Authors
Top Kudoed Authors
Users online (93,693)