Reputation: 11629
I am wondering if I can get last month and current month in Redshift? I looked at functions at http://docs.aws.amazon.com/redshift/latest/dg/r_CURRENT_DATE_TIME_functions.html
For current month, I guess I can do the following:
LEFT(CURRENT_DATE, 7)
For previous month, I came up with the following:
LEFT(ADD_MONTHS(CURRENT_DATE, -1), 7)
But I am wondering if there is a simpler way of doing these?
Upvotes: 9
Views: 27482
Reputation: 8125
SELECT EXTRACT(month FROM CURRENT_DATE);
SELECT EXTRACT(month FROM CURRENT_DATE - '1 month'::interval);
Upvotes: 13