Home > Back-end >  Postgres timezone_minute function with explicit type casts
Postgres timezone_minute function with explicit type casts

Time:01-26

I have two columns, date and time, both strings. I can concatenate them to get a column timestamp.

I need to use the timezone_minute() function. I have tried various formats for the parameter, but have repeatedly faced the error

Query 1 ERROR: ERROR:  function timezone_minute(timestamp without time zone) does not exist
LINE 1: select timezone_minute('2023-01-25T05:36:48Z'::date AT TIME ...
               ^
HINT:  No function matches the given name and argument types. You might need to add explicit type casts.

For example

-- function timezone_minute(timestamp without time zone) does not exist
select timezone_minute('2023-01-25T05:36:48Z'::date AT TIME ZONE 'UTC');
    
-- function timezone_minute(timestamp with time zone) does not exist
select timezone_minute('2023-01-25T05:36:48Z'::date AT TIME ZONE 'UTC');

select timezone_minute('2023-01-25T05:36:48Z'::timestamptz);
select timezone_minute(cast('2023-01-25T05:36:48Z' as TIMESTAMP));

-- etc

How do I correctly utilise timezone_minute - the documentation is severely lacking for this particular function, unfortunately.

I don't fully control the final query, hence the need to use this function. The generated query utilises timezone_minute(), I can essentially set the argument.

CodePudding user response:

the documentation is severely lacking for this particular function, unfortunately.

Yes, because it's not a function.

It is an argument to the extract() function:

select extract(timezone_minute from '2023-01-25T05:36:48Z'::timestamptz);
  • Related