web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Error in "Difference" ...
Power Automate
Answered

Error in "Difference" between dates and extracting days of difference

(1) ShareShare
ReportReport
Posted on by 465
Hi all,
I've this case to retrieve days between 2 dates:
  int(split(dateDifference('2023-05-01''2023-05-05'),'.')[0]) - Result of the difference before split 4.00:00:00
after split and int is equal to 4 
....
my problem born when the dates are the same:
  int(split(dateDifference('2023-05-05''2023-05-05'),'.')[0]) - Result of the difference before split 00:00:00
and the split give me an error because there is no day in the first place, where the divider is the point (.) and not double point (:).
...
Hi need help or any idea to resolve this problem.
Thanx in advance
 
Categories:
I have the same question (0)
  • Verified answer
    Expiscornovus Profile Picture
    33,830 Most Valuable Professional on at

    Hi @diepic,

     

    You can check if there is a dot in the result with an indexOf function before you split. If it equals -1 there is no dot available and you can simply use 0. In other cases you use your split expression.


    Below is an example

     

     

    if(equals(indexOf(dateDifference('2023-05-05','2023-05-05'), '.'), -1), 0, int(split(dateDifference('2023-05-05','2023-05-05'),'.')[0]))

     

     

  • DiePic Profile Picture
    465 on at

    Hi @Expiscornovus 

    thank you for your suggestion.
    It's working

  • Expiscornovus Profile Picture
    33,830 Most Valuable Professional on at

    Hi @diepic,

     

    Did you copy/paste the code sample I shared or did you change your existing expressions from your opening post?

     

    In case of the latter can you make sure there is a comma character between the two date values? I noticed a typo in the expressions you shared in your opening post. The comma was missing between the two dates '2023-05-05''2023-05-05'.

     

    The format for the date difference should be:

    dateDifference('<startDate>', '<endDate>')

     

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Haque Profile Picture

Haque 592

#2
Valantis Profile Picture

Valantis 340

#3
11manish Profile Picture

11manish 284

Last 30 days Overall leaderboard