Pergunta

How to store system time in minutes in a variable in stored procedure of PL/SQL?

I want to store system date in minutes in a variable of stored procedure.

Foi útil?

Solução

How to store system time in minutes in a variable

You can use localtimestamp function to get current date and time in a session timezone, extract hours, minutes, seconds and based on those data calculate value for minutes.

SQL> declare
  2    l_val number;
  3  begin
  4    l_val := (extract(hour from localtimestamp) * 60) +
  5              extract(minute from localtimestamp) +
  6             (extract(second from localtimestamp)/60);
  7   dbms_output.put_line(to_char(sysdate, 'hh24:mi:ss" = "') || concat(to_char(l_val, 'fm99990.00'),' minutes'));
  8  end;
  9  /

09:52:26 = 592.44 minutes

PL/SQL procedure successfully completed
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top