Skip to content
Advertisement

Querying for users who have NOT completed a survey today and Receiving an error

I have a feature I am working on and I need my PostgreSQL db to return all the users that have not completed a survey today.

I am using a left join to join on my survey results table and filtering by customer_id and where the survey_results.created < today but I am using a date part and extract to get the date. If there is better way to do that chime in but that is what I have.

I am receiving this output when running my query instead of results.

Advertisement

Answer

Rather than using datepart, compare it with current_date –

If your survey_results.created_at column is timestamp, use date function to convert it to date then compare it to current_date –

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement