Add minutes to time.

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

Post Reply
rullbandspelare
Pro Scripter
Posts: 149
Joined: Tue Mar 23, 2004 9:11 pm

Add minutes to time.

Post by rullbandspelare » Thu Aug 13, 2009 9:56 pm

Hi!
I know that

Code: Select all

let>bl=1971-03-22
add>bl,10
Gives a correct calculation of dates. I.e bl=1971-04-01

But what about time?
I have tried
let>bl=10:55
add>bl,10

But this gives me an error.

What is the easiest way to add and subtract minutes from a certain time?

Thanks!

rullbandspelare
Pro Scripter
Posts: 149
Joined: Tue Mar 23, 2004 9:11 pm

Post by rullbandspelare » Thu Aug 13, 2009 10:25 pm

If there is no easy way i will try it like this instead. Problem if over midnight , but for my purpose it works.

Code: Select all

//Let>nowshutdown=14:45
//let>addition=18

Separate>nowshutdown,:,time
let>hours=time_1*60
let>totaltime=hours+time_2
let>newtime=totaltime+addition
let>hours={int(%newtime%/60)}
Let>minutes={int((frac((%newtime%/60)-%hours%))*60)}


User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Fri Aug 14, 2009 7:24 am

Use the VBScript time functions:

Code: Select all

VBSTART
VBEND

//add ten minutes to current time
VBEval>DateAdd("n",10,now),new_time

//or add 60 minutes to specific time
VBEval>DateAdd("n",60,"18:30"),new_time

//Get out Hour, Min, Sec portions
VBEval>Hour("%new_time%"),hour
VBEval>Minute("%new_time%"),min
VBEval>Second("%new_time%"),sec
See VBScript docs:
http://msdn.microsoft.com/en-us/library ... S.85).aspx

Also:
http://www.mjtnet.com/blog/2006/01/23/u ... variables/
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts