Dear,
I have two Column Start & End both are Datetime data type.
The Data is
Start End
12:30 15:00
The Total min is 150
i used below query
DATEDIFF(mi, dbo.Trn_Daily3.Dr_TimeStart, dbo.Trn_Daily3.Dr_TimeEnd)
Its giving correct result=150
But when i convert into hour
DATEDIFF(mi, dbo.Trn_Daily3.Dr_TimeStart, dbo.Trn_Daily3.Dr_TimeEnd)/60
then result is 2 but actual 150/60=2.5
How to do it.
Please help on this
Thanks
Basit.
2 Replies
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Vinitha TPosted Nov 23, 2021, 2:19 PM
CAST() function is used to convert any data type value into specified data type
Here datatype may be integer type so results in 2, we can cast it to Float or Decimal to get exact result
Float - approximate data type, round up the value
Decimal - Fixed Precision data type, doesn't round up the value.
SELECT CAST(DATEDIFF(mi, dbo.Trn_Daily3.Dr_TimeStart, dbo.Trn_Daily3.Dr_TimeEnd) AS FLOAT) / 60
Manas MohapatraPosted Nov 19, 2015, 6:32 AM