How do I calculate elapsed time?
I'm writing %%System Time.TimeAndDate%% to a User Time property called "HVAC.AC Run".
Then a few minutes later I'm trying to perform
%%System Time.TimeAndDate%%-%%HVAC.AC Run%% and sending it to a User TimeSpan property.
Obviously it's not working and I'm getting th error...
Unable to parse default time span value ["Year=2008, Month=01, Day=22, Hour=20, Minute=42, Second=41"-"Hour=00, Minute=00"]
Thanks
Tim
Elapsed time
Anyone? Scott?
How do a calculate how long a property has had the same value?
i.e. Property Values...
Fan (boolean)
Fan Run Time (Time and Date)
Fan Elapsed (Timespan)
When Fan changes from 0 to 1, I write the system time to the Fan Run Time property.
When Fan changes back to 0, I need to know who long it was set to 1.
I'm trying "System Time"-"Fan Run Time" using PV and in a script and can't get it to work, nor can I think of another way to do it without parsing out the time string completely in a script.
Tim
How do a calculate how long a property has had the same value?
i.e. Property Values...
Fan (boolean)
Fan Run Time (Time and Date)
Fan Elapsed (Timespan)
When Fan changes from 0 to 1, I write the system time to the Fan Run Time property.
When Fan changes back to 0, I need to know who long it was set to 1.
I'm trying "System Time"-"Fan Run Time" using PV and in a script and can't get it to work, nor can I think of another way to do it without parsing out the time string completely in a script.
Tim
Check DateDiff function in VBScript
Here is a sample that shows the duration in minutes:
TestTimeScript.StartTime is a Time property set to handle Time and Date.
Here is a sample that shows the duration in minutes:
Code: Select all
StartTime = GetPropertyValue( "TestTimeScript.StartTime" )
CurrentTime = GetPropertyValue( "System Time.TimeAndDate" )
MsgBox DateDiff("n",StartTime,CurrentTime)
Thanks,
Scott J
aka spike5884
Scott J
aka spike5884
-
- HouseBot Guru Extraordinaire
- Posts: 1121
- Joined: Tue Sep 28, 2004 7:49 am
- Location: The Netherlands
It's too bad we don't have a simple epoch date available. Meaning amount of seconds from a baseline like 01-01-1978 or so until now. That always gives a single value in seconds and it is very easy to calculate time differences in seconds of of it.
I am with Spike. Have a task put your start time in a property and use a different property for end time. Once end time gets set, trigger a script that calculates the difference using DateDiff. That way you can be sure all remains fine even when the fan is turned on just before midnight and turned off just after midnight. It might be possible using stuff you wrote in your first post, but I haven't used that much so I couldn't tell you why or what goes wrong.
If you have a running script doing your fan control for you, you might even run all of these variables internally in the script without having to create tasks and properties to trigger and store these values.
I am with Spike. Have a task put your start time in a property and use a different property for end time. Once end time gets set, trigger a script that calculates the difference using DateDiff. That way you can be sure all remains fine even when the fan is turned on just before midnight and turned off just after midnight. It might be possible using stuff you wrote in your first post, but I haven't used that much so I couldn't tell you why or what goes wrong.
If you have a running script doing your fan control for you, you might even run all of these variables internally in the script without having to create tasks and properties to trigger and store these values.