Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Subtract integer from datetime

Author  Topic 

Jas
Yak Posting Veteran

51 Posts

Posted - 2011-05-13 : 09:03:03
I have the following query:

TimeBreakStart = case when datediff(minute, '24:00:00', ClockIn) < ShiftEndTime then BreakStart else datediff(minute, '24:00:00', ClockIn) end,

I am getting the folloing error:

The conversion of a char data type to a datetime data type resulted in an out-of-range datetime value.

How can I fix this?

sunitabeck
Master Smack Fu Yak Hacker

5155 Posts

Posted - 2011-05-13 : 09:55:40
The error is telling you that it cannot convert '24:00:00' to a valid datetime. You can convert '23:59:59.667' to datetime (which will give you 1900-01-01 23:59:59.667, but not '24:00:00'.

What is the business logic you are trying to implement?
Go to Top of Page
   

- Advertisement -