cancel
Showing results for
Did you mean:
New Member

## Get calendar event length (in minutes)

I'm using the O365 upcoming calendar event to trigger my slack status (via HTTP webhook) when a meeting is going to start. https://docs.microsoft.com/en-us/connectors/office365/#onupcomingeventsv2

There is no trigger for when a calendar event is going to end so instead I want to set the slack status to automatically expire after the length of the meeting. In order to do that I need to get the length of the meeting in minutes (e.g. 60)

I was trying to do some math on start time and end time but I couldn't find a way to convert the time into epoc or similar numerical format to be able to do addition on it.

Can a variable be added to the triggerBody or is there another way someone can think to get the value I need?

1 ACCEPTED SOLUTION

Accepted Solutions

Hi @jgarr I've had to use a bit of maths to calculate the difference between the start and end time. For ease of explanation I've broken it down into separate actions, but the expression could be combined if you wanted to consolidate it.

From my trigger, I'm going to need the Start time and end time

Variable 1: Date Difference

I have used this expression to subtract the number of ticks for the end date and start date. In a 30 minute meeting I have returned the following value: 18000000000

sub(ticks(triggerBody()?['End']),ticks(triggerBody()?['Start']))

Variable 2: Seconds

I have used another expression to work out the number of seconds which have been returned from the number of ticks. Based on the 30 minute meeting, this has return 1800 seconds

div(variables('DateDiff Ticks'),10000000)

Variable 3: Minutes

I have used a calculation here to divide the number of seconds by 60 to calculate the number of minutes, e.g. in my example it would return 30 minutes. You can then use this to perform the rest of your Flow.

div(variables('Difference Seconds'),60)

If you have found this post useful, please give it a thumbs up. If it has answered your question, please accept it as the solution so others can benefit.

@MattWeston365

If you liked my response, please consider giving it a thumbs up. THANKS!

Proud to be a Flownaut!

Community Leader: Black Country PowerApps & Flow User Group

3 REPLIES 3

Hi @jgarr I've had to use a bit of maths to calculate the difference between the start and end time. For ease of explanation I've broken it down into separate actions, but the expression could be combined if you wanted to consolidate it.

From my trigger, I'm going to need the Start time and end time

Variable 1: Date Difference

I have used this expression to subtract the number of ticks for the end date and start date. In a 30 minute meeting I have returned the following value: 18000000000

sub(ticks(triggerBody()?['End']),ticks(triggerBody()?['Start']))

Variable 2: Seconds

I have used another expression to work out the number of seconds which have been returned from the number of ticks. Based on the 30 minute meeting, this has return 1800 seconds

div(variables('DateDiff Ticks'),10000000)

Variable 3: Minutes

I have used a calculation here to divide the number of seconds by 60 to calculate the number of minutes, e.g. in my example it would return 30 minutes. You can then use this to perform the rest of your Flow.

div(variables('Difference Seconds'),60)

If you have found this post useful, please give it a thumbs up. If it has answered your question, please accept it as the solution so others can benefit.

@MattWeston365

If you liked my response, please consider giving it a thumbs up. THANKS!

Proud to be a Flownaut!

Community Leader: Black Country PowerApps & Flow User Group

New Member

This is simultaniously crazy and awesome! Thanks for replying.

quick question. Is there any reason to do this in three steps instead of combining it into 1 or having 2? I couldn't find a reason to not do div(div(variables('DateDiff Ticks'),10000000),60) but maybe there's something I missing with your approach.

No reason for three steps other than illustration. Feel feee to consolidate it

If you liked my response, please consider giving it a thumbs up. THANKS!

Proud to be a Flownaut!

Community Leader: Black Country PowerApps & Flow User Group

Announcements

#### Community Challenge - Giveaways!

Participate in the Power Virtual Agents Community Challenge

#### 2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

#### Microsoft Learn

Check out our new Discover Your Career Path blog post series and get all the details.

Top Solution Authors
Top Kudoed Authors
Users online (1,570)