Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us in NYC Sept 4th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
SteveMcCabe
Contributor
Contributor

Filtering on Date

Hi,

I'm new to Qlik and looking for some help/advice on how to filter some data.

I have a read only connection into a PostgreSQL database. I have a table containing all orders since the company started. I essentially want to filter the data by date so that I only get the results back for the last 5 years.

I've tried this but keep getting an error

Where Date(Date#(order_date,'D-M-YYYY')) > '12-31-2020' but keep getting an error.

Any help or pointers would be appreciated.

 

Labels (2)
1 Reply
Oleg_Troyansky
Partner Ambassador/MVP
Partner Ambassador/MVP

Hi Steve,

I believe you get an error because you are trying to use Qlik functions, like Date#(), in a SQL statement. Instead, try to use PostgreSQL functions, or simply compare date fields without applying any functions.

By default, I believe PostgreSQL dates are stored as 'YYYY-MM-DD'. If this is how your dates are stored, I'd try something like this:

WHERE order_date > '2020-12-31'

If your dates are stored differently, then use PostgreSQL date functions to bring the dates to YYYY-MM-DD format, in order to make them comparable as strings.

Hopefully this helps,