Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Transforming date with Redshift

I am creating an end of month variable, that works with postgres but I have to rewrite it in Redshift, any clue why it shows me the following error?

The database reported a syntax error: Amazon Invalid operation: Interval values with month or year parts are not supported Details: ----------------------------------------------- error: Interval values with month or year parts are not supported code: 8001 context: i

select
(date_trunc('month', ("Date (id created)" + INTERVAL '1 month'))) as "EoM"
from id
like image 973
ColRow Avatar asked Jul 31 '26 23:07

ColRow


1 Answers

Redshift uses dateadd to apply intervals to timestamps

select date_trunc(month, ( dateadd(month,1,"Date (id created)"))) as "EoM"
from id

see https://docs.aws.amazon.com/redshift/latest/dg/r_DATEADD_function.html

like image 136
Jon Scott Avatar answered Aug 02 '26 15:08

Jon Scott