Tasker Date/Time Calculations.

4,919 views
Skip to first unread message

Tom

unread,
Apr 3, 2012, 10:44:27 AM4/3/12
to Tasker
I was wondering does Tasker have the ability to perform add/subtract
calculations to date/time values. I`ve seen and tried methods where
you use VARIABLE SPLIT on the %TIME and %DATE variables and then use
VARIABLE ADD on the resulting 'child' variables.

But it becomes tricky if you want to add 2 hours to the current time
as you need to consider if you need to advance the date as well (e.g.
if it's 11pm at night then plus 2 hours take you to the next day).

It would be great if you could do actual date/time calculations on a
combined date/time variable. Or am I just missing something?

For those who are interested in what I`m trying to achieve I want to
create a SMS template that is auto-populated with both the current
date and time on one line and on the next line I want to include the
current date and time plus two hours.

I`ve done all of the above except the 'plus two hours' piece as it
seemed to get very complicated in trying to take date rollover into
consideration (i.e. the 11pm scenario above).

Pent

unread,
Apr 3, 2012, 1:18:11 PM4/3/12
to Tasker
> It would be great if you could do actual date/time calculations on a
> combined date/time variable. Or am I just missing something?

%TIMES has current time in seconds. You can use Variable Convert
to get another time in seconds and then do maths on the two values,
use the / and % maths operator to get things like 'remaining minutes'
etc.

Pent

Pent

unread,
Apr 3, 2012, 1:19:24 PM4/3/12
to Tasker
p.s. once you have your new time in seconds, use Variable Convert to
get it in months, hours, minutes etc.

By working in seconds and then converting back you don't have to
think about any rollover.

Pent

Tom

unread,
Apr 17, 2012, 12:39:40 PM4/17/12
to tas...@googlegroups.com
ok thanks - I`ll give that a shot.
 
I need to work out if the current time is near (i.e. within 5 mins) 15,30, 45 or 00 minutes past the hour then do some calculations. Based on what you`ve said it should be possible - thanks for the suggestion.
 
Tom

UncleMike

unread,
Apr 18, 2012, 12:45:50 AM4/18/12
to tas...@googlegroups.com
I think this could be done pretty easily.  If you want to know if it's 5 minutes or less past the quarter hour, you could do something like this:

Variable Set %timepast %TIMES % 900
If %timepast <= 300
<do something>
End If
Reply all
Reply to author
Forward
0 new messages