Skip to main content

Hello Forum,

 

We will have a polygon dataset of construction sites. The dataset will be managed within QGIS collaboratively by several planning officers.

 

When the officer adds a new polygon object they will add a end date. This is the end date of the individual construction site project. Once that end date is reached the record needs to be deleted.

 

I could ask them to manually delete it in QGIS when the date is due. However I’d like to take that overhead off them and replace it with an automated way of deleting records.

 

Is it possible to build in a process to consider the end date value and then filter records accordingly? One port would go to all records where the end date has not yet been breached (this will be my published layer). The second port would filter all records where the end date has been reached (this will become a ‘historics’ layer). I’m assuming the end date value would need to be in a particular format (datestamp, perhaps).

 

Thanks,

Stuart

 

 

Different ways to solve this.

One way is to use a Tester transformer to test if the difference between the EndDate and CurrentDate is positive or negative.

@DateTimeDiff(@Value(EndDate),@DateTimeNow(),days)

Records that need to be moved need to be inserted into the historics table and need to be deleted from the actual layer.

 

But the easier route would be to use one table as source in QGIS but add it as two different layers and use the Filter functionaliity to display only the actual features in actual and the historical features in historical.


Thanks for tht, nielsgerrits .

 

And would the date values need to be in a certain format (datestamp, American date format etc.)? And would the attribute type need to be ‘date’ or would character be OK?


nielsgerrits ​​​​​regarding your first option, where in the Filter does @DateTimeDiff(@Value(EndDate),@DateTimeNow(),days) go? I assuming it’s one of the Test Clauses? Do I set up one test clause or two?


nielsgerrits ​​​, I’ve tried End date > @DateTimeNow()​​

 

But that sends the four records to the Failed port. I was hoping it would send the two records where end date is 20240518 to the passed port, and the other two to the failed port.

 

Or am I just barking up the wrong tree here? 

 

Note that this is using imaginary data for now. But the production data will look similar.


Thanks for tht, nielsgerrits .

 

And would the date values need to be in a certain format (datestamp, American date format etc.)? And would the attribute type need to be ‘date’ or would character be OK?

For @DateTimeDiff() it should be FME date, yyyymmdd. This can be done using the DateTimeConverter.

  

nielsgerrits ​​​​​regarding your first option, where in the Filter does @DateTimeDiff(@Value(EndDate),@DateTimeNow(),days) go? I assuming it’s one of the Test Clauses? Do I set up one test clause or two?

In a Tester:

Attached a sample workspace.

  

nielsgerrits ​​​, I’ve tried End date > @DateTimeNow()​​

 

But that sends the four records to the Failed port. I was hoping it would send the two records where end date is 20240518 to the passed port, and the other two to the failed port.

 

Or am I just barking up the wrong tree here? 

 

Note that this is using imaginary data for now. But the production data will look similar.

The result of @DateTimeNow() is a bigger number as it also has hours, minutes, seconds, so if you want to test this it should be EndDate > @Left(@DateTimeNow(),8) to compare date to date.


Reply