Re: Timestamp conversion Error in dynamic sql script

From: Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at>
To: sud <suds1434(at)gmail(dot)com>, pgsql-general <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Re: Timestamp conversion Error in dynamic sql script
Date: 2024-04-02 08:08:44
Message-ID: 0b5cb6d1e2174f8993511e31f40d5d7f08d48ec4.camel@cybertec.at
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Tue, 2024-04-02 at 11:08 +0530, sud wrote:
> Not able to figure out why it's giving below error during timezone conversion
> while defining the partitions even though I used the typecast? 
>
> [...]
> DECLARE
> start_date TIMESTAMP := '2022-01-01';
> [...]
>     TO_CHAR(start_date + i, 'YYYY_MM_DD')
>
> ***********
> SQL Error [42883]: ERROR: operator does not exist: timestamp without time zone + integer
> Hint: No operator matches the given name and argument types. You might need to add explicit type casts.

As the error states, you cannot add an integer to a timestamp.

What is the supposed meaning of that addition?

Yours,
Laurenz Albe

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Laurenz Albe 2024-04-02 08:16:00 Re: Not able to purge partition
Previous Message sud 2024-04-02 05:38:03 Timestamp conversion Error in dynamic sql script