I have a date column in my_table and I would like to add three months to it. The AWS Redshift documentation suggests using DATEADD or ADD_MONTHS, but I'm getting the following error messages.
With DATEADD:
SYNTAX_ERROR: line 2:13: Column 'month' cannot be resolved
With ADD_MONTHS:
SYNTAX_ERROR: line 2:5: Function add_months not registered
This is what my data looks like:
select
my_date
from
my_table
limit 3
| my_date |
|---|
| 2019-03-01 |
| 2019-04-01 |
| 2019-05-01 |
I would like to do the following:
select
add_months(my_date, 3) as plus3m
from
my_table
limit 3
| plus3m |
|---|
| 2019-06-01 |
| 2019-07-01 |
| 2019-08-01 |
Athena and Redshift are different products. You can find the link to SQL reference in https://docs.aws.amazon.com/athena/latest/ug/ddl-sql-reference.html.
You will need to use date_add('month', 3, my_date) in Athena.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With