Hi, I have a database table with a date column containing dates formatted as YYYYMMDD. I need to select all records from the table with a date ranging from the current date to 5 years previous of the current date. Any assistance appreciated.
Solved
Select records from the previous 5 years based on the current date
Best answer by david_r
What type of database is this? Most databases can do this in a simple where-clause, e.g. Oracle:
WHERE my_timestamp BETWEEN add_months(trunc(sysdate), -12*5) AND sysdate
Or SQL Server:
WHERE my_timestamp BETWEEN DateAdd(yy, -5, GetDate()) AND GetDate()
Or PostgreSQL:
WHERE my_timestamp BETWEEN NOW() - INTERVAL '5 years' AND NOW()
You can then use this where-clause in either a regular reader, a FeatureReader or a SQLExecutor. This will be a lot faster than reading the entire table contents into FME and filter there.
Reply
Rich Text Editor, editor1
Editor toolbars
Press ALT 0 for help
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.