SELECT in postgresql does not take records in the time range

Asked

Viewed 119 times

1

I have the following SELECT

SELECT * FROM motoqueiros WHERE now() - INTERVAL '8 SECONDS' <= data_update

It works on my local machine. I created a server on AMAZON, the server has Ubuntu 14 64 bits, when running the same select does not bring the results, I have to put 20,000 seconds to return something. I’ve changed the time zone to America / Sao Paulo and nothing, has anyone ever been through this kind of thing? thanks!

  • 1

    Checked if the Postgresql version is the same?

  • There is 9.3 the pc is 9.4

  • If possible, run SQL: SELECT data_update, now() FROM motoqueiros ORDER BY data_update DESC LIMIT 15 and ask your question so we can take a look.

  • gave that result brother "2016-08-10 10:32:53" - "2016-08-10 13:32:54.549232+00"

1 answer

1


I believe your problem is still the time zone issue, as your return from now() ends with +00, and our zone (America/Sao_paulo) is -03.

Try the following:

SELECT * FROM motoqueiros WHERE now() AT TIME ZONE 'America/Sao_Paulo' - INTERVAL '8 SECONDS' <= data_update

To resolve the problem at once, edit your postgresql.conf with the following entry:

timezone = 'America/Sao_Paulo' 
  • This solution worked out brother, I noticed here that when I reboot in Ubuntu it returns the previous Timezone, there is no other way not to do it in the OS no?

  • Just save the entrance timezone in the postgresql.conf (is in the answer).

  • vdd, hadn’t noticed, vlw!

  • Do not forget to mark the answer as correct. Abs

Browser other questions tagged

You are not signed in. Login or sign up in order to post.