cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
PowerApper25
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
WarrenBelz
Super User
Super User

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
PA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Welcome Super Users.jpg

Super User Season 2

Congratulations, the new Super User Season 2 for 2021 has started!

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Top Solution Authors
Top Kudoed Authors
Users online (1,540)