Link to home
Create AccountLog in
Avatar of hidrau
hidrauFlag for Brazil

asked on

how to add minutes to my hours?

Hello guys

I have this code:

declare @start_time time;
declare @elapse_time time;

set @start_time =  '13:30:00'
Set @elapse_time= '00:30:00'

SELECT DATEADD(mi, @start_time, @elapse_time)

Open in new window


How is the correct form?

thanks
SOLUTION
Avatar of Vitor Montalvão
Vitor Montalvão
Flag of Switzerland image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
SOLUTION
Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
Avatar of hidrau

ASKER

ok, I understood.

If I have this value  '01:10', I should convert the value to integer and add to my dateadd.

In this case, '01:10' how could I convert the value to integer in a correct way so the result would be 70?
In that case it will be 14:40

No need to convert to INT. the function dateadd will automatically handle it.

/*------------------------

declare @start_time time;
declare @elapse_time time;

set @start_time =  '13:30:00'
Set @elapse_time= '01:10:00'

SELECT DATEADD(SECOND,DATEDIFF(SECOND,'00:00:00',@start_time),@elapse_time) AS finalTime
------------------------*/
finalTime
----------------
14:40:00.0000000

(1 row(s) affected)

Open in new window

edited my last comment.
Avatar of hidrau

ASKER

Pawan,

declare @PREVISAO_INICIO datetime;
declare @TEMPO_ESTIMADO  varchar(10);

set @PREVISAO_INICIO = '20171101 13:00:00'
set @TEMPO_ESTIMADO  = '001 00:30:00'   -- ddd hh:mm:ss


how to make this calc in MSSQL
ASKER CERTIFIED SOLUTION
Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
Avatar of hidrau

ASKER

Pawan, you helped me a lot.

Thank you very very much
Avatar of hidrau

ASKER

thanks a lot