getting data from postgresql for one week

Trying to get data for one week from the DB but it does not work, when I try for one day it works fine here is my one day script that works fine:

WHERE start_stamp at time zone 'America/New_York' >= TIMESTAMP 'yesterday'::timestamp at time zone 'America/New_York'
and start_stamp at time zone 'America/New_York' <  TIMESTAMP 'today'::timestamp at time zone 'America/New_York'

and here is my one-week scrip that does not work:

WHERE time > now () - interval '1 week';

here is the error message I have got

ERROR: syntax error at or near ";"

not sure if this is the right statement but I posted one of what I have tried so far.

Upvotes: 0

Views: 1235

Answers (1)

eshirvana
eshirvana

Reputation: 24568

it should be like this :

select ...
from tablename
where start_stamp at time zone 'America/New_York' >= now() at time zone 'America/New_York' 
  and start_stamp at time zone 'America/New_York' < now() at time zone 'America/New_York' - interval '1 week';

alternatively you can use between as well.

Upvotes: 1

Related Questions