postgresql - How to get current month and Last month in Redshift -


i wondering if can last month , current month in redshift? looked @ functions @ http://docs.aws.amazon.com/redshift/latest/dg/r_current_date_time_functions.html

for current month, guess can following:

left(current_date, 7) 

for previous month, came following:

left(add_months(current_date, -1), 7) 

but wondering if there simpler way of doing these?

select extract(month current_date);  select extract(month current_date - '1 month'::interval); 

Comments

Popular posts from this blog

ruby on rails - RuntimeError: Circular dependency detected while autoloading constant - ActiveAdmin.register Role -

c++ - OpenMP unpredictable overhead -

javascript - Wordpress slider, not displayed 100% width -