Jump to content

Elapsed Time but with Date and Time

Recommended Posts

Dear all


In my application I have to measure the elapsed time between 2 events that can happen on 2 different timestamps on the calender.




What is the time elapsed between 20-01-2016 16:35:55 and 19-04-2015 14:41:22?

If I can have the elapsed time value as a number that can be converted afterwards in Years, Months, Days, Hours, Minutes and Seconds, that's ok.

If it can be directly displayed as a result from a End Time and Start Time Substraction, is also ok.


I'm using the V350 and can display the actual time using the link to SI30 to the Variable UTC, this works.

The problem is that when I store SI30 to a DW variable it only saves the seconds and not the complete time stamp (= Year, Month, Day, Hours, Minutes, Seconds) in seconds, so every 60s it goes back to 0s.

As a consequence the elapsed time is corrupt: sometimes values are also negative and only in seconds,  45s-59s= negative value of course


I would like to store the Start Time Stamp in DW0 as a number and the End Time Stamp in DW1 as a number and substract DW1-DW0 and save it in DW3.

DW3 should then give me the elapsed time in Years, Months, Days, Hours, Minutes, Seconds.  Here it gives me only seconds and wrong values.

It seems SI30 is giving me the complete Time Stamp on the Display if using a Variable UTC but if you work with the SI30 and store it in DW variables it only stores seconds and not the complete Time Stamp.


I would like some help to calculate the elapsed time between 2 calender events.


Any help is welcome!


Link to comment
Share on other sites



What is the end result you are looking for?  The elapsed time between two calendar events in total seconds?  Or in a Years, Months, Days, Hours, Minutes, Seconds difference?


If you are trying to get the RTC into a DW, you can use the RTC to UTC function block in the ladder (Utils > Clock > UTC > RTC to UTC).  This will take SI30 through SI34 and put the RTC into a UTC format.  With this, you can perform calculations for a time event difference.  If you use the UTC to RTC function block, you can take the time difference and get the RTC value into 5 integers; the format for the integers is as follows:


First MI = seconds (SS)

Second MI = time (HHMM)

Third MI = date (DDMM)

Fourth MI = year (YYYY)

Fifth MI = day (1-7)


Hope this helps.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...