Skip to main content

Notifications

Power Apps - Error Handling
Answered

Error: IF statement for comparing Today's date with 'Greater than' and 'Less than' - Power Apps

(1) ShareShare
ReportReport
Posted on by 57
Hi all,
 
I need to find a solution for Power Apps to make different decisions/actions dependent on Today's date.
 
Eg:
If it's between dd/mm/yyyy and dd/mm/yyyy, do THIS,
If it's between dd/mm/yyyy and dd/mm/yyyy, do THIS2,
If it's between dd/mm/yyyy and dd/mm/yyyy, do THIS3,
 
I tried using the 'Greater than' and 'Less than' symbols, but it's not adding up properly and hoping someone can find out why or offer another solution.
 
The statements used so far have been:
 
If((18/01/2025)<((DateValue(Today()), "Yes", "No") 
(Works: Prints "Yes")
 
If((DateValue(Today()))<(25/01/2025),"Yes","No")
(Wrong: Prints "No")
 
I think this is also having an effect on other formulas that include it, as I also tried the combined formula:
 
 
If((18/01/2025)<(DateValue(Today()))<(25/01/2025),"Yes","No"))
 
and that doesn't work either.
(Comes out as an error, but the date is 20/01/2025, which is after 18/01/2025 and before 25/01/2025)

 
I even replaced the formulas with basic numbers to make sure I hadn't just muddled up the symbols or anything: It didn't help. The formulas worked fine with numbers, but not with dates.
 
Am I missing something?
  • Ytalo Silva Profile Picture
    Ytalo Silva 41 on at
    Error: IF statement for comparing Today's date with 'Greater than' and 'Less than' - Power Apps
     
    Hello, could you validate my suggestion if it works so I can mark the post as answered? I would be extremely grateful.😀
  • Ytalo Silva Profile Picture
    Ytalo Silva 41 on at
    Error: IF statement for comparing Today's date with 'Greater than' and 'Less than' - Power Apps
    I believe that to confirm, you should validate my suggestion, haha! Thank you for the feedback. I'm happy to help.😀
  • CU09091727-0 Profile Picture
    CU09091727-0 57 on at
    Error: IF statement for comparing Today's date with 'Greater than' and 'Less than' - Power Apps
     
    Perfect response!
     
    Thank you so much. This is exactly what I was looking for.
     
    I knew it was something so simple, but couldn't the errors in my coding or 'see the wood for the trees' (as they say)!
     
    I added in the DateValue(" ") adjustments as described and it's now working exactly as I hoped.
     
    Now I can start adding all of the more complex actions that are dependent on these condition statements. Cheers. :)
     
     
     
    How do I confirm your response as the answer? It's only showing a tick box but no button to save/accept/confirm. It also won't let me respond directly to other people's comments/suggestions, which is odd. Only changed recently, so I wonder if it's an update to the site.
     
     
  • WarrenBelz Profile Picture
    WarrenBelz 145,445 on at
    Error: IF statement for comparing Today's date with 'Greater than' and 'Less than' - Power Apps
    Another suggestion here if you are hard-coding dates
    If(
       Date(2025,1,18) < Today(),
       "Yes", 
       "No"
    ) 
     
  • Verified answer
    Ytalo Silva Profile Picture
    Ytalo Silva 41 on at
    Error: IF statement for comparing Today's date with 'Greater than' and 'Less than' - Power Apps

    Hello, I see that you are trying to use dates to make certain decisions. However, you are using (18/01/2025) instead of DateValue("18/01/2025"). When we use only (18/01/2025), the compiler assumes we are trying to divide the numbers 18, 01, and 2025.

    To compare dates, both values need to be in date format, and there are two easy ways to achieve this:

    1. The first would be to place 18/01/2025 inside a variable and then compare it with Today().
    2. The second would be to place 18/01/2025 as text inside DateValue.

    Here’s a possible solution:

    1.

    2.

     

    I hope this was helpful.😀

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Microsoft Kickstarter Events…

Register for Microsoft Kickstarter Events…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Announcing Forum Attachment Improvements!

We're excited to announce that attachments for replies in forums and improved…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 145,445

#2
RandyHayes Profile Picture

RandyHayes 76,287

#3
Pstork1 Profile Picture

Pstork1 64,741

Leaderboard

Featured topics