简体   繁体   中英

Postgres timezone_minute function with explicit type casts

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.

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);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM