Solved

Get the logged in time

Posted on 2000-05-10
8
117 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
  • 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
 
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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

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…

707 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now