Cody Cook Cody Cook - 5 months ago 25
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!

Answer

I think this will work::

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