Skip to main content
Question

Calculate the time difference between two features in a non-spatial dataset

  • August 21, 2014
  • 3 replies
  • 116 views

Hi all,

 

 

I have a dataset (from MS Access) that has fields as follows:

 

 

Site Name       Sample Date/Time     

 

A                        08/16/2014 08:00

 

A                        08/17/2014 14:00

 

A                        08/25/2014 12:30

 

B                       07/04/2014 11:00

 

B                       08/04/2014 11:00

 

B                       09/04/2014 11:00

 

 

I want to be able to calculate the time in days, hours or minutes between each feature and the preceeding one (i.e. how long between each sample at each site) where the site name is the same.  The output would then look like this...

 

 

Site Name       Sample Date/Time    TimeSinceLast (hours)

 

A                        08/16/2014 08:00       -

 

A                        08/17/2014 14:00       30

 

A                        08/25/2014 12:30       190.5

 

B                       07/04/2014 11:00        -

 

B                       08/04/2014 11:00        744

 

B                       09/04/2014 11:00        744

 

 

Any ideas greatly appreciated.  I'm very new to FME, just done the Basic Desktop Webinar.

 

 

Thanks, Alice
This post is closed to further activity.
It may be an old question, an answered question, an implemented idea, or a notification-only post.
Please check post dates before relying on any information in a question or answer.
For follow-up or related questions, please post a new question or idea.
If there is a genuine update to be made, please contact us and request that the post is reopened.

3 replies

david_r
Celebrity
  • August 21, 2014
Hi,

 

 

you can use an AttributeCreator to get a reference to a preceeding feature's sample date:

 

 

 

 

Then format both the current and the preceeding sample date into the number of seconds since epoch:

 

 

 

 

Finally, calculate the difference between the two values and convert seconds to hours:

 

 

 

 

David

fmelizard
Safer
Forum|alt.badge.img+21
  • Safer
  • August 21, 2014
Or just download the DateDifferenceCalculator from the FME Store.

takashi
Celebrity
  • August 21, 2014
Hi,

 

 

In addition to David's suggestion, you can use Conditional Value setting in the AttributeCreator to differentiate sequences of each Site. That is, only if the Site Name is equal to the previous feature's Site Name, assign feature[-1].SampleDateTime to PrevSampleDateTime.

 

 

 

And then, calculate the time difference if the PrevDateTime is not empty.

 

 

Takashi