cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
jgarr
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)

 

Calc.PNG

 

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





Did my reply help? Please give it a thumbs up.
Did I answer your question? Please mark my post as a solution!
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

View solution in original post

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)

 

Calc.PNG

 

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





Did my reply help? Please give it a thumbs up.
Did I answer your question? Please mark my post as a solution!
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

View solution in original post

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




Did my reply help? Please give it a thumbs up.
Did I answer your question? Please mark my post as a solution!
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

Helpful resources

Announcements
MBAS Attendee Badge

Claim Your Badge & Digital Swag!

Check out how to claim yours today!

MPA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

secondImage

Are Your Ready?

Test your skills now with the Cloud Skill Challenge.

Top Solution Authors
Users online (54,815)