PSQL timezones and select query

94 Views Asked by At

I am currently stuck on trying to get some results from a database due to different timezones and the way the records are kept. It is a table that has 4 columns: timestamp, recordid, name, accountnumber.
When I run a simple query:

Select * from table;

I get the results that I need but the timestamp field is in GMT time.

What I am trying to run is a query to get the last 30 minutes of records with:

Select * from table where timestamp::time >= (Current_time - interval '30 minutes') and timestamp::time < (current_time);

but from this query, I get 0 records returned, even though I know that it should be there.

I have tried to convert both fields to UTC, using "at time zone 'UTC'" command, also tried using now() instead of current_time.

I have now been working on this for 2 days, so I am running out of time and patience - any help would be appreciated. I am running version 8.3.

Regards,

0

There are 0 best solutions below