Flow - Calculate Date Diference
Definition :- ticks(timestamp: string) - Returns the number of ticks (100 nanoseconds interval) since 1 Jan 1601 00:00:00 UT
Scenario :-
SharePoint list contains following columns:-
Title (Single Line of Text)
Contract Executed Date (Date)
MS Flow :-
Get items from list
Run Select data operation to calculate number of days between Today's date and the Contract Executed Date
The expression for Days Since Contract Executed :-
Comments
-
Flow - Calculate Date Diference
Thanks! I finally figured it out!
div(div(mul(sub(ticks(item()?['responseDate']),ticks(item()?['requestDate'])),100),1000000000),60) -
Flow - Calculate Date Diference
@AnnetteM It looks like the difference in the video you watched is that the expression he used did an extra conversion. I think he was like using an expression to get hours and then used the same one to get minutes but just added an additional divide by 60. I'm not exactly sure, but the examples above should get the result you want.
You can look at my post here that shows about time calculation.
I would recommend you go into the Get Help With Power Automate - Building Flows and make a new post asking how to get the time difference in approvals. Title your post something like "Help to Get Time Difference for Approval Request and Response" or similar.
Write your question, give a couple of screenshots of your flow, and I can almost guarantee someone will answer your exact question shortly. It might be difficult for you to get flow specific help here on an older blog post comments.
-
Flow - Calculate Date Diference
I am trying to get the time difference between the start and wait for approval's request date and response date. The expression listed above appears to be different than what is in @Mdorrani YouTube video "SharePoint Approval Timeline..." I tried importing the github flow, but it errors out. Any help would be appreciated.
-
Flow - Calculate Date Diference
I have made a post that thoroughly shows the use of the expression dateDifference() as well as how to use the ticks() expression to find the difference between two datetimes.
https://powerusers.microsoft.com/t5/General-Power-Automate/Using-the-dateDifference-expression-or-ticks-to-find-difference/td-p/2195863 -
-
Flow - Calculate Date Diference
The best way I have debugged things like that is to make a series of compose statements where each compose uses the output from the previous and does one action of the formula. So the first compose would have the ticks expression, then, the second would have the sub expression, then mul....etc.
-
Flow - Calculate Date Diference
Writing the expressions is a science. Is there an expression helping tool. We have just spent hours try to debug this
div(div(mul(sub(ticks(item()?['responseDate'])!ticks(item()['requestDate'])/(100,100000000],60)
@Mdorrani By the way I love your videos and am trying to keep up! -
Flow - Calculate Date Diference
DateDiff is available in Power Apps, which means it should be in PowerFX, so hopefully just a matter of time to get it into Power Automate.
That said, for a scenario where you are using the SharePoint -> Get Items, and you need to filter on something past due (lets say 2 or more days past due) based on a date field in the SharePoint list, this ODATA filter worked for me:
myDueDateColumn le '<the expression below>'
Expression: formatDateTime(addDays(utcNow(),-2),'yyyy-MM-dd')
-
-
Flow - Calculate Date Diference
This solution is working great for me however does it take leap years into account? When I've tried this some of the calculations are 1 day off and it appears the ones with a day missing are where there is a leap year between today and the end date? I'm doing the sum the other way round from the example so End Date - Today. Thanks
*This post is locked for comments