[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 127
  • Last Modified:

Get the logged in time

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
prosit
Asked:
prosit
  • 3
  • 3
  • 2
1 Solution
 
TimCotteeCommented:
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
 
pjknibbsCommented:
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
 
TimCotteeCommented:
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
Independent Software Vendors: 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!

 
prositAuthor Commented:
It will always be the same day.

(they have to go home at some point :)

t
0
 
prositAuthor Commented:
U got it, works great!

t
0
 
pjknibbsCommented:
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
 
TimCotteeCommented:
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
 
pjknibbsCommented:
TimCottee: Sorry I was a bit snappy--3 o'clock in the afternoon in a steaming hot office syndrome. <G>
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 3
  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now