Skip to main content
Question

How to filter "latest" date attribute?

  • December 7, 2015
  • 2 replies
  • 369 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

2 replies

erik_jan
Contributor
Forum|alt.badge.img+17
  • 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
erik_jan wrote:

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.


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings