DateDiff returns INT, divided by 24 still returns INT--i want decimal (1 Viewer)

OuterApply

New member
Local time
Today, 00:59
Joined
Mar 10, 2022
Messages
15
Datediff(hour,startdatetime,stopdatetime) returns INT.

Datediff(hour,startdatetime,stopdatetime)/24 still returns INT.

I want a decimal or two on there, so that I can calculate partial days (it all adds up when aggregating).

What's the proper solution and understanding of same?
 

OuterApply

New member
Local time
Today, 00:59
Joined
Mar 10, 2022
Messages
15
Oh I see an article now -

datediff(Anything,Startdatetime,Stopdatetime)/Something.0

works great.
I knew that two integers divided would return an integer, but I had tried and failed to cast one as a decimal because somehow simply wrapping the datediff in a cast as decimal...didn't work.

Anyway.
 

theDBguy

I’m here to help
Staff member
Local time
Today, 00:59
Joined
Oct 29, 2018
Messages
21,358
Oh I see an article now -

datediff(Anything,Startdatetime,Stopdatetime)/Something.0

works great.
I knew that two integers divided would return an integer, but I had tried and failed to cast one as a decimal because somehow simply wrapping the datediff in a cast as decimal...didn't work.

Anyway.
Congratulations! Glad to hear you got it sorted out and thanks for sharing your discovery. Good luck with your project.
 

Users who are viewing this thread

Top Bottom