# Better logic calculate time

**URL:** <https://community.homey.app/t/better-logic-calculate-time/28714>\
**Category:** Questions & Help\
**Created:** [April 20, 2020, 6:54pm UTC](https://community.homey.app/t/better-logic-calculate-time/28714 "2020-04-20T18:54:54Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![Edgar](https://avatars.discourse-cdn.com/v4/letter/e/b487fb/32.png) [@Edgar](https://community.homey.app/u/Edgar)\
**Post date:** [April 20, 2020, 6:54pm UTC](https://community.homey.app/t/better-logic-calculate-time/28714/1 "2020-04-20T18:54:55Z")

</div>

hi all,

for a very long time i would like to calculatie time.  
In a variable (String) i have: 09:30  
i would like to substract 75 minutes from it or add hours (whatever).

How can i do that?

I cannot find any solutions for it, not on github and not on here. Please help!

Edit:  
What was said here: [Time calculations in Better logic](https://community.homey.app/t/time-calculations-in-better-logic/11078/3)

i dont understand at all.

---

<div class="post-metadata">

**Author:** ![DirkG](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/dirkg/32/118897_2.png) [@DirkG](https://community.homey.app/u/DirkG)\
**Post date:** [April 21, 2020, 5:58am UTC](https://community.homey.app/t/better-logic-calculate-time/28714/2 "2020-04-21T05:58:25Z")

</div>

Hi Edgar,

Where does the 9:30 come from? What are the +/- 75 minutes needed for?

Please give an example, maybe I can help you then.

---

<div class="post-metadata">

**Author:** ![Edgar](https://avatars.discourse-cdn.com/v4/letter/e/b487fb/32.png) [@Edgar](https://community.homey.app/u/Edgar)\
**Post date:** [April 21, 2020, 7:12am UTC](https://community.homey.app/t/better-logic-calculate-time/28714/3 "2020-04-21T07:12:25Z")

</div>

thnx for your reply and that you wanne look into it.

the time can excist on multiple reasons. But in this case it is the time when i have to start to work tomorrow. To determine this i use iCalandar to Voice app.

But there is no option for to determine when you are done working. The app doesn’t support endtime of appointment. But i work full time so i can add 8,30 hours and then i know when i am free.  
Also, when i have to work at 9.30 then my alarmclock have to go off 75 minutes earlier.

My alarmclock works allready fully but i want to have more 🙂

---

<div class="post-metadata">

**Author:** ![DirkG](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/dirkg/32/118897_2.png) [@DirkG](https://community.homey.app/u/DirkG)\
**Post date:** [April 21, 2020, 10:06am UTC](https://community.homey.app/t/better-logic-calculate-time/28714/4 "2020-04-21T10:06:52Z")

</div>

I think there are several possibilities:

- create a separate appointment in the linked calendar (iCalandar) for the start **and** the end of working time
- use the Chronograph App (or similar) to create a timer/countdown over 8 hours and 30 minutes. Start the timer/countdown at the start of work. After the timer/countdown (8 hours 30 minutes) has expired, an action can be performed (e.g. start another flow)

A few more questions about your alarm clock or wake-up time. Which two alarm times do you need exactly? Which time? How did you enter the different working hours in the calendar? 09:30 - 18:00 and 10:45 - 19:15?

---

<div class="post-metadata">

**Author:** ![Edgar](https://avatars.discourse-cdn.com/v4/letter/e/b487fb/32.png) [@Edgar](https://community.homey.app/u/Edgar)\
**Post date:** [April 21, 2020, 2:33pm UTC](https://community.homey.app/t/better-logic-calculate-time/28714/5 "2020-04-21T14:33:28Z")

</div>

Thnx! But that is not what i want, i want to know when i am done working (when i will be free).  
f.e. i want to know today, when i will be free tomorrow… as long as iCalendar 2 voice doesnt have the option to read the endtime, i only can assume it is 8,5 ours later, but i cannot add this to start time.

---

<div class="post-metadata">

**Author:** ![DirkG](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/dirkg/32/118897_2.png) [@DirkG](https://community.homey.app/u/DirkG)\
**Post date:** [April 21, 2020, 3:03pm UTC](https://community.homey.app/t/better-logic-calculate-time/28714/6 "2020-04-21T15:03:33Z")

</div>

I’m on the road at the moment and can’t try much. I will test something later and get back to you.  
I may have to sleep on it for a night as well. 😉

---

<div class="post-metadata">

**Author:** ![DirkG](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/dirkg/32/118897_2.png) [@DirkG](https://community.homey.app/u/DirkG)\
**Post date:** [April 21, 2020, 3:09pm UTC](https://community.homey.app/t/better-logic-calculate-time/28714/7 "2020-04-21T15:09:15Z")

</div>

If not done yet, you can also have a look at the official post of the “iCalendar to Voice” app, maybe there are some ideas to solve your problem.

> [@iCalendar to Voice by Raymond Brink \[not supported - use IcalCalendar\]](https://community.homey.app/t/icalendar-to-voice-by-raymond-brink/4236/64):
>
> I use it every day to start car warmer. I have several flows checking outdoor temperature 120, 90, 60 and 30 min before appointment with the name “Car warmer”. But if you are trying out you need to consider that the app checks calender with the interval set in the app. And I have noticed that I need to force update from mobile calender after setting new appointment.

---

<div class="post-metadata">

**Author:** ![Edgar](https://avatars.discourse-cdn.com/v4/letter/e/b487fb/32.png) [@Edgar](https://community.homey.app/u/Edgar)\
**Post date:** [April 21, 2020, 5:16pm UTC](https://community.homey.app/t/better-logic-calculate-time/28714/8 "2020-04-21T17:16:50Z")

</div>

i asked several times, even on github, but no response. app seems to be dead sadly.

thanks you like to check out things. i hope it is possible. like the link i posted before here, it should be possible. but i dont understand what is says. maybe you do?

---

<div class="post-metadata">

**Author:** ![DirkG](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/dirkg/32/118897_2.png) [@DirkG](https://community.homey.app/u/DirkG)\
**Post date:** [April 21, 2020, 6:11pm UTC](https://community.homey.app/t/better-logic-calculate-time/28714/9 "2020-04-21T18:11:18Z")

</div>

Performing calculations and writing the calculated value to a variable is not the big problem.  
To do calculations with a time is not possible in my opinion, at least I don’t know how. In my opinion, only calculations with natural numbers and decimal numbers are possible. Therefore I try to find another way like you imagined it.  
So if you could just write down the flow as it should look like in theory so that I understand your requirement better.

---

<div class="post-metadata">

**Author:** ![Edgar](https://avatars.discourse-cdn.com/v4/letter/e/b487fb/32.png) [@Edgar](https://community.homey.app/u/Edgar)\
**Post date:** [April 22, 2020, 6:58am UTC](https://community.homey.app/t/better-logic-calculate-time/28714/10 "2020-04-22T06:58:41Z")

</div>

It is actualy very simple:

if iCalendar to voice appointmen is in 12 hours  
and appoitment (tag=afspraak) = work  
then: workstarttime = afspraak (lets say it is 08:00)  
write notification: your alarmclock is set to 06:45 (- 75 minutes)  
write variable: workendtime = entime

if this works, then i bet i can create others, like adding minutes or hours myself.

---

<div class="post-metadata">

**Author:** ![DirkG](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/dirkg/32/118897_2.png) [@DirkG](https://community.homey.app/u/DirkG)\
**Post date:** [April 22, 2020, 10:46am UTC](https://community.homey.app/t/better-logic-calculate-time/28714/11 "2020-04-22T10:46:32Z")

</div>

Sorry, I guess I can’t help you.  
I can’t get the iCalender app to read “Work” (name of the appointment) from the calendar. It always shows only “Test”. Do you?  
And to calculate the time does not work (in my opinion). Are you able to fill a variable with a time? If so, then probably only a text variable and no numeric variable with which you can make calculations, right?  
Is it possible to fill one variable with the hours and another variable with the minutes? Then you could calculate the time at least in minutes or in hours (with decimal). I’m not sure if this could help.

I did my best, but unfortunately it was not enough… 🤷🏽‍♂️

---

<div class="post-metadata">

**Author:** ![Marcel\_Ubels](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/marcel_ubels/32/18860_2.png) [@Marcel\_Ubels](https://community.homey.app/u/Marcel_Ubels)\
**Post date:** [April 22, 2020, 11:22am UTC](https://community.homey.app/t/better-logic-calculate-time/28714/12 "2020-04-22T11:22:40Z")

</div>

What i had sometime ago before Homey crashed and lost all flows was a variable time for running flows. You cannot use time in a variable( tried everything)but you can use numbers. In the countdown app you can use a variable with numbers. In that case numbers represent seconds. For my case i needed to know how long a flow ran until it ended. When the flow started a timer started; for instance 1000 sec. When the flow ended, the remaining seconds were put into a variable. Then a new flow calculated the time the flow ran. This number was set into a variable. This number i used for a timer that started with that number as second(as a tag). I also added some seconds for security reasons. Maybe this is something which can help you with your puzzle.

---

<div class="post-metadata">

**Author:** ![Edgar](https://avatars.discourse-cdn.com/v4/letter/e/b487fb/32.png) [@Edgar](https://community.homey.app/u/Edgar)\
**Post date:** [April 22, 2020, 9:05pm UTC](https://community.homey.app/t/better-logic-calculate-time/28714/13 "2020-04-22T21:05:53Z")

</div>

too bad… however it is strange if it can’t be done.  
Thank you for trying @DirkG

but yes, when you test icalendar 2voice, you can edit the word test, but you can also test with the word test off course. It is for sure not possible with icalendar.  
but maybe (or as i read in the link in my OP) it should be possible with Better Logic but i don’t know how.

@Marcel_Ubels no, that doesn’t work for me. i just have a variable: 08:00 and i wanne subtract 75 minutes from it, so my alarmclock should go off at 06:45

---

<div class="post-metadata">

**Author:** ![zakraket](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/zakraket/32/17470_2.png) [@zakraket](https://community.homey.app/u/zakraket)\
**Post date:** [May 12, 2022, 1:51pm UTC](https://community.homey.app/t/better-logic-calculate-time/28714/14 "2022-05-12T13:51:25Z")

</div>

Same issue here, still no solution?

I want my car to start charging X minutes (device (car) \> charging time left) before a set time (the time I want to leave)

---

<div class="post-metadata">

**Author:** ![JPe4619](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/jpe4619/32/9017_2.png) [@JPe4619](https://community.homey.app/u/JPe4619)\
**Post date:** [May 12, 2022, 2:51pm UTC](https://community.homey.app/t/better-logic-calculate-time/28714/15 "2022-05-12T14:51:06Z")

</div>

Maybe you can calculate it with HomeyScript, like in:

> [@HomeyScript seconden naar uren, minuten en seconden](https://community.homey.app/t/homeyscript-seconden-naar-uren-minuten-en-seconden/47643):
>
> Echt super nuttig is dit niet, maar wel leuk voor de mensen die graag dingen bijhouden. Ik heb dit HomeyScript gemaakt om de uitkomst van een stopwatch leesbaarder te maken. Ik heb deze apps daarvoor in gebruik: Met chronograph kun je een stopwatch starten en stoppen. De tijd daartussen wordt opgeslagen in de tag: looptijd (s) Dit is dan opgeslagen in seconden, bijvoorbeeld 42123 seconden. Maar dan weet je nog niet bijster veel. Dus… als je dan het volgende invult bij Als dan zie je de uitk…

Or the app: Flow Utilities?
