Deprecated: Function get_magic_quotes_gpc() is deprecated in /home2/tonyso97/public_html/libraries/f0f/input/input.php on line 102

Deprecated: Function get_magic_quotes_gpc() is deprecated in /home2/tonyso97/public_html/libraries/f0f/input/input.php on line 102

Deprecated: Function get_magic_quotes_gpc() is deprecated in /home2/tonyso97/public_html/libraries/f0f/input/input.php on line 102
Firebird Cálculo com Data

Select

    /*diferenca de anos entre DATANASC E ADMISSAO */

    datediff(year from DATANASC to DATAADMISSAO ) ANOS_DATANASC_ADMISSAO,

    /*diferenca de dias entre a data de DATAADMISSAO e a data atual*/

    datediff(day from DATAADMISSAO to current_timestamp) DIAS,

    /*calcula horas restantes*/ 

    trunc(trunc(cast(datediff(minute from DATAADMISSAO to current_timestamp) as numeric(9,2)) / 60) - 

        (datediff(day from DATAADMISSAO to current_timestamp) * 24)) HORAS, 

    /*calcula minutos restantes*/ 

    mod(cast(datediff(minute from DATAADMISSAO to current_timestamp) as numeric(9,2)), 60) MINUTOS, 

    /*concatenacao*/ 

    cast( 

        /*verifica dias*/ 

        (case datediff(day from DATAADMISSAO to current_timestamp) 

         when 0 

         /* menos de 24 horas*/ 

         then '' 

         else 

         /* dias completos*/ 

         datediff(day from DATAADMISSAO to current_timestamp) || ' dias, ' 

         end 

         ) || 

        /*verifica horas*/ 

        (case 

        /*menos de 60*/ 

         when trunc(cast(datediff(minute from DATAADMISSAO to current_timestamp) as numeric(9,2)) / 60) < 60 

            then 

                trunc(cast(datediff(minute from DATAADMISSAO to current_timestamp) as numeric(9,2)) / 60) 

                else 

                /*mais de 1 minuto - extrai as horas completas deixando apenas minutos*/ 

                trunc(trunc(cast(datediff(minute from DATAADMISSAO to current_timestamp) as numeric(9,2)) / 60) - 

                    (datediff(day from DATAADMISSAO to current_timestamp) * 24)) 

       end) 

    || ' horas e ' || 

    /*extrai os minutos*/ 

    mod(cast(datediff(minute from DATAADMISSAO to current_timestamp) as numeric(9,2)), 60) 

        || ' minutos' as varchar(50)) Resumo 

From zteste