• Status: Solved
• Priority: Medium
• Security: Public
• Views: 130

# Get the logged in time

I have two variables containing the time.

Both are strings:

txtLogoutTime   ' 06:03:55 PM

Guess what I want :)  I want to know how long they were logged in.

This should be an easy one.

t
0
prosit
• 3
• 3
• 2
1 Solution

abs(datediff("s","08:54:11","06:03:55")) will return 10216 which is the number of seconds between the two times. You can then work out minutes and hours easily.

Hope this helps.
0

Commented:
Use the CDate function to convert your times to a Variant of type Date, then subtract them.

The result will be another Variant:Date containing the difference between the two times...I think!!
0

pjknibbs, subtracting two date values in this way will give you a decimal value representing the number of days between them:

?(cdate("08:54:11") - cdate("06:03:55") )
returns  0.118240740740741
which mulitplied by 60 * 60 * 24 to get the seconds is 10216 as per my previous example.
0

Author Commented:
It will always be the same day.

(they have to go home at some point :)

t
0

Author Commented:
U got it, works great!

t
0

Commented:
TimCottee: You hadn't posted your answer when I wrote mine--check the times out! I wasn't attempting to steal the question out from under you, if that's what you're implying.
0

I wasn't trying to imply that you were stealing pjknibbs, just clarifying your method which though different would have worked perfectly well given that you have to multiply up to get the correct answer. I apologise for any implication, it certainly wasn't intended.
0

Commented:
TimCottee: Sorry I was a bit snappy--3 o'clock in the afternoon in a steaming hot office syndrome. <G>
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.