Time in minutes.

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

JBurger
Junior Coder
Posts: 33
Joined: Wed Nov 12, 2003 7:16 pm
Location: NY

Post by JBurger » Thu Dec 07, 2006 4:42 pm

Bob Hansen wrote:But what JBurger is looking for sounds like he may have imported the time from some other process, and assigned it to Time2. So he will still need to parse the time into the correct format.
Bob, That is exactly what I am doing.

I used the VBS suggestion from Marcus, but I set get the string error.

Here is my script. What am I doing wrong??

Code: Select all

VBSTART
VBEND

//ASSIGN VARIABLES
Let>IFile=C:\Macros\configs\HVAC.ini

//At start of script/process get current time 
VBEval>Now(),StartTime


ReadIniFile>IFile,CONTROL,LTime,rLTime

Label>Main
VBEval>TimeValue("%rLTime%"),TimeRes


VBEval>datediff("n","%StartTime%","%TimeRes%"()),MinsElapsed

The time is just a normal time eg 9:00:00 AM

Thanks for helping
-Joe

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 » Thu Dec 07, 2006 4:54 pm

Joe, can you provide an example of exactly what is being read from the INI file?

What is the vallue of rLTime ?
Is 9:00:00 AM typical of the format?
Last edited by Bob Hansen on Thu Dec 07, 2006 4:56 pm, edited 1 time in total.
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!

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

Post by Marcus Tettmar » Thu Dec 07, 2006 4:55 pm

The last time should be:

VBEval>datediff("n","%StartTime%","%TimeRes%"),MinsElapsed
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

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

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

Post by Marcus Tettmar » Thu Dec 07, 2006 5:00 pm

As the Now() function adds a date, I'd do this:

VBEval>datediff("n",TimeValue("%StartTime%"),"%TimeRes%"),MinsElapsed

Or, better:

Code: Select all

VBSTART
VBEND

//ASSIGN VARIABLES
Let>IFile=C:\Macros\configs\HVAC.ini

//At start of script/process get current time 
VBEval>Time(),StartTime

ReadIniFile>IFile,CONTROL,LTime,rLTime

Label>Main
VBEval>TimeValue("%rLTime%"),TimeRes


VBEval>datediff("n","%StartTime%","%TimeRes%"),MinsElapsed
The above use the Time() function rather than the Now() function which includes a date component. Your value from your ini file has no date component.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

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

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 » Thu Dec 07, 2006 5:03 pm

AAArgh!

Remove the extra () in the DateDiff line
-------------------------------------------------

Edited......I see that Marcus just found the same error. We are almost in sync......
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!

JBurger
Junior Coder
Posts: 33
Joined: Wed Nov 12, 2003 7:16 pm
Location: NY

Post by JBurger » Thu Dec 07, 2006 6:16 pm

LOL That worked.

I looked at that line a 100 times and didn't see that.

Thanks guys!!

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