I've seen a lot of threads on this topic, but nothing that really gets at something fundamental that I'm trying to achieve in PowerApps and maybe would help someone else. Here's my example code:
If(
Today()>10/01/2023 And Today() < 10/01/2024, Set (varFY, "FY2023")
)
This seems incredibly straightforward but the evaluation fails in a way that doesn't make sense to me.
I'm trying to say that If Today is after 10/01/2023 AND before 10/01/2024 Then the variable should be this.
The way this evaluates basically determines Today() (or Now() if I swap that in) to be greater than (and true) no matter what the other static date given is... why?!
Wrapping things in Text() doesn't seem to make a difference. There must be something obvious that I'm missing because this seems like it would be a very straightforward calculation....
Ah yes using the date function is def needed as well as having the correct years of course! Good catch yourself! Teamwork makes the Power Apps work... or whatever they say!
Good catch @mmollet - though that wasn't it. I reformatted my code snippit for clarity. Again unless I'm missing something I seem to have resolved (and got the behavior I wanted) with the following:
If(
Today()>Date(2022,10,01) And Today()<Date(2023,10,01), Set(varFY, "FY2023")
)
If this is the exact code you have in your app then you are missing a closing parethesis at the end. You close the set function but never close the If statement afterwards. This may cause Power Apps to not evaluate those function calls properly.
Also no date is after a date that hasn't happened yet which would be the case for any date returned by Today() or Now() until October 2nd. The current year is 2023 so you would need to change 2023 to 2022 and 2024 to 2023 to make this evalue to anything other than false right now.
Basically your formula is If(false And true) which will always evaluate to false.
MS.Ragavendar
20
BCBuizer
10
Super User 2025 Season 1
LC-26081402-0
10