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

Notifications

Announcements

Community site session details

Community site session details

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

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

(1) ShareShare
ReportReport
Posted on by 463
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,189 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
    463 on at

    Hi @Expiscornovus 

    thank you for your suggestion.
    It's working

  • Expiscornovus Profile Picture
    33,189 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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 538 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 405 Moderator

#3
abm abm Profile Picture

abm abm 252 Most Valuable Professional

Last 30 days Overall leaderboard