Time

General Macro Scheduler discussion

Moderators: Dorian (MJT support), JRL

Post Reply
Ross Lainchbury
Newbie
Posts: 5
Joined: Sat Dec 27, 2003 3:45 am

Time

Post by Ross Lainchbury » Sat Apr 17, 2004 2:12 am

I need to send the Time as Hours and Mins ie 17:25.
Needs to be the current time plus 30 mins.
Dammed if I can work out how to do it
Some help would be appreciated
Ross of Christchurch New Zealand

User avatar
Bob Hansen
Automation Wizard
Posts: 2475
Joined: Tue Sep 24, 2002 3:47 am
Location: Salem, New Hampshire, US
Contact:

Post by Bob Hansen » Sat Apr 17, 2004 5:09 am

Here is something you may be able to use. I did this for someone else with a siimilar request some months ago. I have a variable Advance that can be changed. Advance is the amount of time in minutes that you want to add. Controls had to be included to go to the next hour and possibly to the next day. This uses a 12 hour AM/PM presentation.

Just run the macro and it will show the current system time and the time increased by the Advance variable.
Let>Advance=30
Hour>Hours
If>%Hours%Hours=%Hours%-12

Label>NextTime
Min>Minutes
Sec>Seconds
//Determine AM or PM, look for space character in current time.
GetTime>Now
Position> ,%Now%,1,Space
MidStr>%Now%,%Space%,3,AMPM
Let>Now=%Hours%:%Minutes%:%Seconds%%AMPM%

Label>AdvanceTime
//Need to modify this area if Advance>60
Let>Minutes=%Minutes%+%Advance%
If>%Minutes%Minutes=%Minutes%-60
//Check for leading 0 in minutes string
Len>%Minutes%,LM
If>%LM%=2,AddHour
//Comment out the next line to stop leading "0" on the minutes.
Let>Minutes=0%Minutes%

Label>AddHour
Let>Hours=%Hours%+1
If>%Hours%ChangeAMPM
Let>Hours=%Hours%-12
If>%AMPM%=AM,MakePM

Label>MakeAM
Let>AMPM=AM
Goto>End

Label>MakePM
Let>AMPM=PM

Label>End
//Check for leading 0 in hours string
Len>%Hours%,LH
If>%LH%=2,Finish
//Comment out the next line to stop leading "0" on the hours.
//Let>Hours=0%Hours%

Label>Finish
Let>Later=%Hours%:%Minutes%:%Seconds%%AMPM%
MessageModal>Time now is %Now%%CRLF%Time later is %Later%
If you cut/paste be sure to remove all Trailing Spaces using the Editor, Edit, Remove Trailing Spaces tool.
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!

adroege
Automation Wizard
Posts: 438
Joined: Tue Dec 07, 2004 7:39 pm

display current time + 30 minutes using VBScript

Post by adroege » Thu May 27, 2010 5:54 pm

This is another way to do it. This should output hh:mm for 30 minutes in the future.

[code]
VBStart
VBEnd

VBEval>DateAdd("n",30,now()),result
VBEval>FormatDateTime("%result%",4),result1
MessageModal>result1
[/code]

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