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:
1WHERE my_timestamp BETWEEN add_months(trunc(sysdate), -12*5) AND sysdate
Or SQL Server:
1WHERE my_timestamp BETWEEN DateAdd(yy, -5, GetDate()) AND GetDate()
Or PostgreSQL:
1WHERE 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.
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.
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.
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.