Solved

Get the logged in time

Posted on 2000-05-10
8
122 Views
Last Modified: 2010-05-02
I have two variables containing the time.

Both are strings:

txtLoginTime    ' 08:54:11 AM
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
Comment
Question by:prosit
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
  • 2
8 Comments
 
LVL 43

Accepted Solution

by:
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

by:pjknibbs
ID: 2796130
Use the CDate function to convert your times to a Variant of type Date, then subtract them.

e.g. CDate(txtLogoutTime) - CDate(txtLoginTime)

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

Expert Comment

by:TimCottee
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
Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

 
LVL 2

Author Comment

by:prosit
ID: 2796168
It will always be the same day.

(they have to go home at some point :)

t
0
 
LVL 2

Author Comment

by:prosit
ID: 2796204
U got it, works great!

t
0
 
LVL 12

Expert Comment

by:pjknibbs
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

by:TimCottee
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

by:pjknibbs
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
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…

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question