How to add Floating(decimal) hour in DateTime's DATEADD function?

sql, sql-server-2008

Solution

You can't. It's well describer on documentation: DATEADD (Transact-SQL)

number

Is an expression that can be resolved to an int that is added to a datepart of date. User-defined variables are valid.

If you specify a value with a decimal fraction, the fraction is truncated and not rounded.

UPDATE

You could try that:

SELECT DATEADD(Second, 0.5 * 60 * 60, GETDATE()) 

Of course - you can change `DATEPART` and multiplier to get desired precision.

Problem

I am trying to add some hours in SQL SERVER using DATEADD function. But when I try this, ``` SELECT DATEADD(Hour, 0.5, GETDATE()) ``` It is not adding 0.5 hour. How to solve this?

Original source