Skip to main content
Question

How to filter "latest" date attribute?

  • December 7, 2015
  • 2 replies
  • 513 views

Forum|alt.badge.img

Hi all,

in a SDF file, i have a date field and I would like filter/extract the record(s) with the latest date. What transformer/parameter should I use?

eg.

ID, DATE

1, 12-13-15

2, 12-13-15

3, 12-01-15

4, 08-01-14

5, 04-01-13

--------------------------

I would like to extract/filter ID 1 and 2 (records with the latest date) in this case.

thank you!!!

W

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.

2 replies

erik_jan
Contributor
Forum|alt.badge.img+26
  • Contributor
  • December 7, 2015

I would use the StatisticsCalculator to get the max_date in an attribute. Make sure you connect to the complete output port. You may have to use DateFormatter if the date fileld is of a string type instead of an actual date.

Then you can use a Tester to test if data = max_date.

That should give you all features that carry max_date as a date.


Forum|alt.badge.img+2
  • December 8, 2015

I would use the StatisticsCalculator to get the max_date in an attribute. Make sure you connect to the complete output port. You may have to use DateFormatter if the date fileld is of a string type instead of an actual date.

Then you can use a Tester to test if data = max_date.

That should give you all features that carry max_date as a date.

Two minor reminders:

- DateFormater over writes the original date so you might want to use AttributeCreator to copy the date first.

- make sure you create the format YYYYMMDD

(format string %Y%m%d) so that StatisticsCalculator actually finds the correct maximum date.