It is currently Thu Apr 17, 2014 9:31 pm




Post new topic Reply to topic  [ 2 posts ] 
 Time between dates, subtracting dates, times 
Author Message
Major
Major

Joined: Wed Sep 30, 2009 2:03 pm
Posts: 101
Post Time between dates, subtracting dates, times
We had a situation where we were tracking run time on a machine, but the owner wanted to know what the EU (Equipment Utilization as a %) for that equipment was. We used two pop-up calendars - one for start date/time, and one for end/date time, used in the query. We already had the total run time for that period, but that had to be subtracted from the total available time for that period. Thus the difference (in minutes) between the start date/time and end date/time had to be determined.
The way to find the difference in minutes between the two dates, which seemed to work best, is to:
1) create three dynamic properties: Start_Time_Long, End_Time_Long, Time_Diff. (all are integers)
2) on the Start and End time properties, create an expression that type casts your dates toLong.
3) this will create long integers out of the dates and times.
4) in the Time_Diff property created and expression that says: (End_Time_Long - Start_Time_Long) / 59983.65.
5) the rsulting integer in the Time_Diff property will be the amount of time in Minutes between the Start date/time and the End date/time.
6) If you need seconds, or hours, etc. you can modify the divisor to get whatever scale is appropriate fo your application.

Hope this helps somebody.


Wed Apr 20, 2011 9:22 am
Profile
Moderator
Moderator

Joined: Sun Apr 02, 2006 2:46 pm
Posts: 4015
Location: Sacramento, CA
Post Re: Time between dates, subtracting dates, times
I know I'm a little late with this, but it would be much easier to do this using the dateDiff expression.

Just bind your Time_Diff integer property to an expression like:
Code:
dateDiff({Root Container.StartDate.Date}, {Root Container.EndDate.Date}, "min")

_________________
Carl Gould
Software Development
Inductive Automation


Fri Apr 29, 2011 7:56 am
Profile WWW
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 


Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: