Cody Cook Cody Cook - 8 months ago 37
MySQL Question

Amazon-Redshift: How to get entries that are a week old

I am trying to write an Amazon Redshift bash script, that once a week, will email me all of the users created in the last week. I have the rest of the query written out, but I cannot figure out how to add a WHERE clause conditional that works like the MYSQL DATE_SUB(). Example:

Select *
from users u
where u.timestamp > DATE_SUB(NOW(), INTERVAL 1 WEEK)

Note: I do not want to manually enter the date every week, I am hoping for just a quick command that can work as a solution to this issue.

Thank you!


I think this will work::

where u.timestamp > dateadd(day, -7, current_date)