N
N
Nikolai Khoziashev2021-12-07 23:41:04
PostgreSQL
Nikolai Khoziashev, 2021-12-07 23:41:04

How to correctly write the to_char function in postgresql?

there is a reports table with a parameters column of type jsonb and keys offset, time
I make a request, described below, to get the time without taking into account the timezone, but that's not the point ... what's wrong with the request? thanks)

SELECT to_char(time parameters->>'time' - interval parameters->>'offset', 'HH24:MI') FROM reports

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Slava Rozhnev, 2021-12-07
@The_Last_Dot

SELECT to_char(
  	to_timestamp(parameters->>'time', 'HH24:MI') - (parameters->>'offset' || ' seconds')::interval,
  'HH24:MI'
) 	
FROM reports;

PostgreSQL fiddle

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question