Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Another date question (SQL 2000) 1

Status
Not open for further replies.

mutley1

MIS
Jul 24, 2003
909

Hi guys,

I had a read through the useful date time items as always, but cant work this one out. I have 2 fields that are datetime for a diabetic - bloodlasteaten and blooddate (when blood is drawn). What i also have is a computed column giving hours between the blood being drawn and the time last eaten. All works fine.

Is there a way to get hours and minutes difference without having to do 2 parts to the statement, as I want to have it (preferably) as a computed column (int currently).
Code:
(datediff(hour,[BloodLastEaten],[BloodDate]))

I have tried a convert decimal (5,2) but it till comes out as a whole number. Either 7.75 or 7:45 for 7 3/4 hrs would be fine, just can it be done as a computed column or do i have to trigger an update where the workings are split into 2 parts?

TIA Guys

M.
 
DateDiff returns in integer. If you want fractional hours, then you need to use minutes for your datediff and divide by 60. You should be able make this a computed column.

(datediff([!]minute[/!],[BloodLastEaten],[BloodDate]) [!]/ 60.0[/!])

-George

"The great things about standards is that there are so many to choose from." - Fortune Cookie Wisdom
 
Thanks George,

Not spoken to you for a good 9 months but you're still the king!!!!

Thanks,

M.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top