2014-08-22

Calculate Time Difference between Two Features

Another solution for this question.
Community: Calculate the time difference between two features in a non-spatial dataset










Table columns definition in the InlineQuerier:












SQL query statement is:
-----
select a.SiteName, a.SampleDateTime,
case
    when b._count is null then null
    else round((a._epochtime - b._epochtime)/3600.0, 1)
end as TimeSinceLast
from Source as a left outer join Source as b
    on b.SiteName = a.SiteName and b._count = a._count - 1
-----

Result:














btw, why there is not datetime type for setting input table columns in the InlineQuerier?
FME 2014 SP3 build 14389
=====
Dale@Safe replied to my question. See his comment. Thanks, Dale!

2 comments:

  1. Hi Takashi,

    The reason we don't expose a datetime is that the InlineQuerier is based on SQLite, and it doesn't have a native datetime type. From this page though http://www.sqlite.org/datatype3.html , in the 1.2 section, they explain how to work with dates in SQLite, which is applies to the Inline Querier.

    ReplyDelete
    Replies
    1. Hello Dale,
      Thanks for the clarification. So, treating the datetime as integer value in the InlineQuelier seems to be a right way :)

      Delete