Multiplication hours x number

2

I have the case of a time worked and his salary for hours. I need to calculate how much they have charged:

SELECT '07:45'::time as horas_trabajadas,
        8.45::numeric(18,2) as precio_hora,
        '07:45'::interval * 8.45 as total_dia

Here the subject is in which% total_dia comes out as:

  

0 years 0 mons 0 days 65 hours 29 mins 15.00 secs

And I need you to tell me what the worker has earned. In this case, it would be: 7.75*8.44 = 65.4875

I think it has to be simple, but I do not see the solution

Here is a Fiddle with the query

    
asked by Txmx 12.12.2018 в 12:44
source

1 answer

2

Here you are:

SELECT
    '07:45'::time as horas_trabajadas,
    8.45::numeric(18,2) as precio_hora,
    (extract(epoch from '07:45'::interval) / 3600) * 8.45 as total_dia;

I found it in the other OS in English: link

    
answered by 12.12.2018 / 15:20
source