I needed to know if there was a way to count the hours a user has been
logged on for. When they first log in, i record the time and when the
logoff i record the time, but now how would i subtract them.. specially if
they log on at 2300hr and log off at 1am in the morning..
thanks
--
AdamPC@dotnet.itags.org.hotmail.comThe Subtract method of the DateTime structure should help you.
DateTime t1 = DateTime.Now;
DateTime t2 = DateTime.Now.AddHours(3);
TimeSpan t3 = t2.Subtract(t1);
"ACaunter" wrote:
> Hi all,
> I needed to know if there was a way to count the hours a user has been
> logged on for. When they first log in, i record the time and when the
> logoff i record the time, but now how would i subtract them.. specially if
> they log on at 2300hr and log off at 1am in the morning..
> thanks
> --
> AdamPC@.hotmail.com
I assume you are doing something along the lines of Session("LoginTime") =
Now then the user logs in. When they log out you could do something along the
lines of:
Dim dt As DateTime = CType(Session("LoginTime"), DateTime)
Dim ts As TimeSpan = Now.Subtract(dt)
This would give you what you are looking for, I think. Have a look at the
help on TimeSpan.
Hope it helps.
Chris.
"ACaunter" wrote:
> Hi all,
> I needed to know if there was a way to count the hours a user has been
> logged on for. When they first log in, i record the time and when the
> logoff i record the time, but now how would i subtract them.. specially if
> they log on at 2300hr and log off at 1am in the morning..
> thanks
> --
> AdamPC@.hotmail.com
Thanks for the help
"Chris Podmore" wrote:
> I assume you are doing something along the lines of Session("LoginTime") =
> Now then the user logs in. When they log out you could do something along the
> lines of:
> Dim dt As DateTime = CType(Session("LoginTime"), DateTime)
> Dim ts As TimeSpan = Now.Subtract(dt)
> This would give you what you are looking for, I think. Have a look at the
> help on TimeSpan.
> Hope it helps.
> Chris.
> "ACaunter" wrote:
> > Hi all,
> > I needed to know if there was a way to count the hours a user has been
> > logged on for. When they first log in, i record the time and when the
> > logoff i record the time, but now how would i subtract them.. specially if
> > they log on at 2300hr and log off at 1am in the morning..
> > thanks
> > --
> > AdamPC@.hotmail.com
0 comments:
Post a Comment