Skip to main content
Question

Select first instance of the hour for a given date

  • June 8, 2023
  • 2 replies
  • 13 views

ldupont

Hi FME,

 

I have a dataset with date/time stamps where I need to retain only the first occurrence in each hour, on a given day.

 

For example:

 

1/1/2000 12:05 --> Keep

1/1/2000 12:10 --> Discard

1/2/2000 12:05 --> Keep

1/2/2000 12:15 --> Discard

1/2/2000 12:59 --> Discard

1/3/2000 12:00 --> Keep

1/3/2000 12:12 --> Discard

 

Thanks for taking a look!

2 replies

geomancer
Evangelist
Forum|alt.badge.img+58
  • Evangelist
  • 932 replies
  • June 9, 2023

Split the date/time step on the space.

Pass the results to a sampler, sample only the first feature, group by date.

This will sample only the first feature entering for each date.

Split_Date_Time


geomancer
Evangelist
Forum|alt.badge.img+58
  • Evangelist
  • 932 replies
  • June 9, 2023

Update.

Your example doesn't show more than one hour per date, but your description does hint at that.

If you want something like

1/1/2000 12:05 --> Keep

1/1/2000 12:10 --> Discard

1/1/2000 13:05 --> Keep

1/1/2000 13:15 --> Discard

the solution presented above will not work.

In that case you can split on ':'