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

Community site session details

Session Id : LdU0u0SFfrgwemw9whihUg
Power Automate - General Discussion
Answered

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

Like (1) ShareShare
ReportReport
Posted on 9 May 2023 13:48:24 by 461
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
 
I have the same question (0)
  • Expiscornovus Profile Picture
    32,379 Most Valuable Professional on 09 May 2023 at 14:59:49
    Re: Error in "Difference" between dates and extracting days of difference

    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>')

     

  • DiePic Profile Picture
    461 on 09 May 2023 at 14:47:50
    Re: Error in "Difference" between dates and extracting days of difference

    Hi @Expiscornovus 

    thank you for your suggestion.
    It's working

  • Verified answer
    Expiscornovus Profile Picture
    32,379 Most Valuable Professional on 09 May 2023 at 14:18:02
    Re: Error in "Difference" between dates and extracting days of difference

    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]))

     

     

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

MS.Ragavendar – Community Spotlight

We are honored to recognize Ragavendar Swaminatha Subramanian as our September…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 736 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 396 Moderator

#3
Power Apps 1919 Profile Picture

Power Apps 1919 339

Last 30 days Overall leaderboard
Loading complete