Solved

# Get the logged in time

Posted on 2000-05-10
117 Views
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
Question by:prosit
• 3
• 3
• 2

LVL 43

Accepted Solution

TimCottee earned 50 total points
ID: 2796124
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

LVL 12

Expert Comment

ID: 2796130
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

LVL 43

Expert Comment

ID: 2796150
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

LVL 2

Author Comment

ID: 2796168
It will always be the same day.

(they have to go home at some point :)

t
0

LVL 2

Author Comment

ID: 2796204
U got it, works great!

t
0

LVL 12

Expert Comment

ID: 2796297
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

LVL 43

Expert Comment

ID: 2796516
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

LVL 12

Expert Comment

ID: 2797077
TimCottee: Sorry I was a bit snappy--3 o'clock in the afternoon in a steaming hot office syndrome. <G>
0

## Featured Post

You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…