2 Replies Latest reply: May 15, 2014 9:51 AM by Grant Perkins

# Time Calculation

Hi guys, long time user of Monarch back from v5-v8 now, but I've never had to do a time duration by seconds calculation, for lack of a better term.

I have two time fields,  the raw data in the file looks like this:

StartTime = 2006-09-01 00:30:38

EndTime = 2006-09-01 00:31:15

Of course if you make it a date time filed when you do your template it converts it to actual time etc..

I need to know the total "Seconds" between these times?  Any ideas?

Thanks guys and gals!

• ###### Time Calculation

Hi Sweptline,

Have a look at a  [url="http://mails.datawatch.com/cgi-bin/ultimatebb.cgi?ubb=get_topic;f=1;t=001329#000001"]similar discussion on duration calculations[/url].

If you create calculated fields to get Date/Time fields for the Calc Start Time:

[font="courier"]ctod(,&quot;y/m/d&quot;,&quot;DT&quot;)  /font[/quote]and the Calc End Time:

[font="courier"]ctod(EndTime,&quot;y/m/d&quot;,&quot;DT&quot;)  /font[/quote]you can then calculate the duration in seconds:

[font="courier"](Time()-Time())*86400  /font[/quote]HTH,

Kruncher

• ###### Time Calculation

Hi Sweptline,

Just subtract one D&T field from the other and multiply by 86400.

If you set the resulting field to numeric and general format you will get seconds. If you set its format to timespan you will get hh:mm:ss

The calculation of the difference between the dates and times gives a result in days and decimal portions of days. Multiplying by the number of seconds in a day gives the answers in seconds.

Or Kruncher's version of course if the Date and Time do not start out in a "date and time" field type.

HTH.

Grant

Edit to observe that Todd beat me to it!     :cool: