How can I add 2 hrs in time in SQL query ?
Question
Application Type
Reactive

Hi All,

I wanted to add the 2 hrs in my existing SQL query attribute (JourneyDate) and I'm using the function (SYSDATE+2) But It's not working here. Below is the select query

e.g : {Trip}.[FromDatetime]  + 2/24 as JourneyDate,

Is this the right way to add the time or is there any other way also to implement this functionality.

Thanks 

Prince

Hi @Prince K,

You can add duration to your column

{Trip}.[FromDatetime] + #duration(0,2,0,0)) as JourneyDate, 

The arguments of #duration are days, hours, minutes, seconds

Thanks, Aadhavan S


Hey Buddy,
You can achieve this by using below format

DATEADD(HOUR,-3,@Date)

You can follow below link
https://sqlhints.com/tag/how-to-add-hours-to-datetime-in-sql-server/

If this helps you then please mark this as solution

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.