Site Sponsored By: SQLDSC - SQL Server Desired State Configuration
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.
I have 2 date/time fields in my table. I also have a float field.I want to get the # of hours between start_time and end_time. I want to calculate this when I update the end_time.UPDATE timetrackSET end_time = '09/24/2003 13:34:33 PM',tot_hours = DATEDIFF(minute, start_time, '09/24/2003 13:34:33')/60(start_time = '09/24/2003 08:00:00 AM')My problem is that tot_hours is always getting set to a whole number. How can I get it to give me decimals?If I do the update without dividing and then do another update and divide the result by 60, I get the correct results.TIA- Vince
tkizer
Almighty SQL Goddess
38200 Posts
Posted - 2003-09-24 : 14:46:48
You have to convert either denominator or the numerator to float. It has to do with order of data types. I converted the numerator below: