I am trying to log the time users are logged in, and I am unable to get any precision.
I would like hours to be displayed with two decimal places of accurate precision, but Datediff rounds to the nearest unit of time. This (IMO) should be fairly easy to overcome by using a smaller unit of time, and dividing that large number by 60 or 3600 (for minute or second), but no luck.
Using the following sessions let's look at what I want, what I've tried, and what I'm getting.
You can post now and register later.
If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.
Question
LWSChad
Hello all;
I am trying to log the time users are logged in, and I am unable to get any precision.
I would like hours to be displayed with two decimal places of accurate precision, but Datediff rounds to the nearest unit of time. This (IMO) should be fairly easy to overcome by using a smaller unit of time, and dividing that large number by 60 or 3600 (for minute or second), but no luck.
Using the following sessions let's look at what I want, what I've tried, and what I'm getting.
SessionID = 1 | LoginDT 8-17-2014 09:00:00 | LogoutDT 8-17-2014 09:15:00
SessionID = 2 | LoginDT 8-17-2014 10:00:00 | LogoutDT 8-17-2014 10:40:00
SessionID = 3 | LoginDT 8-17-2014 11:00:00 | LogoutDT 8-17-2014 13:30:00
Desired Result:
SessionID = 1 | Logged Hours 0.25
SessionID = 2 | Logged Hours 0.67
SessionID = 3 | Logged Hours 2.50
Datediff(hour,[@field:LoginDT],[@field:LogoutDT])
SessionID = 1 | Logged Hours 0.00
SessionID = 2 | Logged Hours 0.00
SessionID = 3 | Logged Hours 2.00
Datediff(minute,[@field:LoginDT],[@field:LogoutDT])
SessionID = 1 | Logged Hours 15.00
SessionID = 2 | Logged Hours 40.00
SessionID = 3 | Logged Hours 150.00
Datediff(minute,[@field:LoginDT],[@field:LogoutDT])/60
SessionID = 1 | Logged Hours 0.00
SessionID = 2 | Logged Hours 0.00
SessionID = 3 | Logged Hours 2.00
(Datediff(minute,[@field:LoginDT],[@field:LogoutDT]))/60
SessionID = 1 | Logged Hours 0.00
SessionID = 2 | Logged Hours 0.00
SessionID = 3 | Logged Hours 2.00
Round(Datediff(minute,[@field:LoginDT],[@field:LogoutDT])/60,2)
SessionID = 1 | Logged Hours 0.00
SessionID = 2 | Logged Hours 0.00
SessionID = 3 | Logged Hours 2.00
Round((Datediff(minute,[@field:LoginDT],[@field:LogoutDT]))/60,2)
SessionID = 1 | Logged Hours 0.00
SessionID = 2 | Logged Hours 0.00
SessionID = 3 | Logged Hours 2.00
Any ideas?
Thanks!
Link to comment
Share on other sites
3 answers to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.