0

I am trying to run the following query. Not sure, what mistake I am doing:

select min(p.start_timestamp AT TIME ZONE p.timezone AT TIME ZONE 'America/Los_Angeles' ) as Date,
 'America/Los_Angeles' AS Timezone, sum(GREATEST(0, p.value)) as Value  
from main.production_m p 
where 
p.start_timestamp AT TIME ZONE p.timezone >= '2017-02-18' 
and p.start_timestamp AT TIME ZONE  p.timezone < '2017-02-22' + INTERVAL '1 day' 

Getting the following error:

ERROR:  invalid input syntax for type interval: "2017-02-20"
LINE 5: ...and p.start_timestamp AT TIME ZONE  p.timezone <= '2017-02-2...

Appreciate your input. Thanks Karthey

4
  • **'2017-02-22'** what are these asterixes doing there? Commented Jun 26, 2017 at 19:59
  • I removed it just now Commented Jun 26, 2017 at 20:09
  • '2017-02-22' + INTERVAL ('1 day') or '2017-02-22' + INTERVAL '1 day'::interval Commented Jun 26, 2017 at 20:26
  • Its working after adding parentheses.. Thanks Nicarus! Commented Jun 26, 2017 at 20:40

1 Answer 1

1

PSQL thinks that your date should be an interval for some reason; you can fix this by casting:

p.start_timestamp AT TIME ZONE  p.timezone < '2017-02-22'::timestamptz + INTERVAL '1 day'
Sign up to request clarification or add additional context in comments.

1 Comment

"Some reason": the reason is point 2.a. of the PostgreSQL operator type resolution rules.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.