Whats wrong with time!

I am trying a very simple thing which seems to work on postgres client dbeaver . However samethings gives weird results in Grafana panels.

I need to select shift start and end time, so I look at now and truncate it to give date and add 5.5hrs interval. BTW I have tried so many things, work arounds… I must be missing something.

select now(), to_timestamp(to_char(now(), 'yyyy-mm-dd') || ' 05:30:00', 'yyyy-mm-dd HH24:min:ss')

DBeaver result:
2022-09-28 17:26:07.682 -0700 2022-09-28 05:30:00.000 -0700

Grafana result:
2022-09-28 17:44:25 2022-09-28 22:30:00

Seems like grafana id doing double timezone conversion, one on the query and second on display.

Original simpler way select now(), date_trunc('day', now()) + ' 05:30:00'

1 Like

Solved it by using the below to be same as select date(now())

SELECT 
            date(now()) + interval '7h' AS date