-4

I'd like to set a start_date and end_date variable using the following:

DECLARE 
  @start_date Date
  @end_date Date
SET @start_date = '2022-02-18'
SET @end_date = '2022-05-18'

The error message is:

ERROR:  syntax error at or near "@"
LINE 2:   @start_date Date
          ^
SQL state: 42601
Character: 12

What's the correct way to set and declare a variable in PostgreSQL?

Thanks!

  • 1
    Postgres does not use `@` for variables. With diligent [research](https://meta.stackoverflow.com/questions/261592/how-much-research-effort-is-expected-of-stack-overflow-users), you should be able to answer last question. – Parfait May 18 '22 at 19:45
  • 1
    How hard is to go here [plpgsql structure](https://www.postgresql.org/docs/current/plpgsql-structure.html) and find the answer? This shows a distinct lack of effort. – Adrian Klaver May 18 '22 at 19:53

0 Answers0