Skip to main content

Notifications

Community site session details

Community site session details

Session Id : sA20CDU4JqETVfLxtNm7aP
Power Apps - Building Power Apps
Unanswered

Dates and Times in Power Fx causing Formula Errors!

Like (0) ShareShare
ReportReport
Posted on 17 Jun 2024 08:29:21 by 32

Hey everyone,

I'm working on a formula in Power Fx that subtracts the end date from today's date. I'm encountering some data type errors because the NOW() function includes both date and time, causing issues with calculations. Ideally, I'd like to use a function that only considers the date portion.

viet561995_4-1718612862099.png

 

In my current formula, even though the end date and the result of NOW() show the same date (e.g., 17/6 or 17 Jun), the difference (DATEDIFF) is -1 instead of the expected 0.
viet561995_3-1718612854690.png


Any suggestions on how to tackle this? I'm looking for ways to calculate date only
Thanks in advance for your help!

  • CU09102019-0 Profile Picture
    2 on 09 Oct 2024 at 20:20:23
    Dates and Times in Power Fx causing Formula Errors!
    Hello,
     
    please try next solution: 
    DateDiff('Date Observed', UTCToday())
  • WarrenBelz Profile Picture
    146,700 Most Valuable Professional on 17 Jun 2024 at 10:35:58
    Re: Dates and Times in Power Fx causing Formula Errors!

    @viet561995 ,

    That is also a very good thing to post initially - I will have to step away here as I do not use them.

  • viet561995 Profile Picture
    32 on 17 Jun 2024 at 08:57:20
    Re: Dates and Times in Power Fx causing Formula Errors!

    Thanks for your reply,

     

    In my case, I'm actually working within the model-driven app, not canvas app. in this model driven app, the Power Fx is in preview mode. Im thinking the TODAY() function might not be available in the preview mode yet so i am trying to find another solution.

     

    Additionally, I can confirm that the End Date field in my model-driven app is set up as a date only type field, so it's not storing any time information.

    viet561995_0-1718614540435.png

     

  • anandm08 Profile Picture
    1,936 Super User 2025 Season 1 on 17 Jun 2024 at 08:51:20
    Re: Dates and Times in Power Fx causing Formula Errors!

    try :

    Abs(DateDiff(
     'End Date',
     Today()
    ))
  • WarrenBelz Profile Picture
    146,700 Most Valuable Professional on 17 Jun 2024 at 08:48:33
    Re: Dates and Times in Power Fx causing Formula Errors!

    Hi @viet561995 ,

    Today() certainly is supported 

    WarrenBelz_0-1718614051284.png

    I am assuming 'End Date' in your formula is actually a valid date field or value.

     

    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.

    MVP (Business Applications)   Visit my blog Practical Power Apps

     

  • viet561995 Profile Picture
    32 on 17 Jun 2024 at 08:42:08
    Re: Dates and Times in Power Fx causing Formula Errors!

    Thanks for the suggestion! Unfortunately, I already tried using TODAY() in Power Fx, but it seems that function isn't supported. That's why I was using NOW() instead.

    viet561995_0-1718613656419.png

     

  • WarrenBelz Profile Picture
    146,700 Most Valuable Professional on 17 Jun 2024 at 08:37:07
    Re: Dates and Times in Power Fx causing Formula Errors!

    Hi @viet561995 ,

    Try

    DateDiff(
     'End Date',
     Today()
    )

     

    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.

    MVP (Business Applications)   Visit my blog Practical Power Apps

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

Understanding Microsoft Agents - Introductory Session

Confused about how agents work across the Microsoft ecosystem? Register today!

Markus Franz – Community Spotlight

We are honored to recognize Markus Franz as our April 2025 Community…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,700 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 66,015 Most Valuable Professional

Leaderboard
Loading started
Loading complete