Seconds/Hours/Days etc.. since user last visited

  • Thread starter Thread starter tdi1686
  • Start date Start date
T

tdi1686

I want to make a table that lists the Seconds / Hours / Days since the user
last visited my site, just like the myPHPnuke systems have, but I dont know
the best way to go about it.

At the moment when the user calls the page the database is updated with the
current date/time for that user.

Should I do this in the VB code in the page or write a SQL statement to do
this?

I have tried in SQL to do this and partly succeeded. Ideally I want it do
display the time in seconds if less than 60 seconds since a visit, minutes
if less than 60 minutes, hours if less than 24 and days if otherwise.

tdi1686
 
It would really be better in terms of performance to simply get the
TimeStamp from the database raw, and then use code in your app to get the
parts out of it. If you do want to split it up in your SQL, you could do
something like the following:

SELECT Year(someDate) As YearPart, Month(someDate) As MonthPart,
Day(someDate) As DayPart, Hour(someDate) As HourPart,
Minute(SomeDate) As MinutePart, Second(someDate) As SecondPart
FROM someTable

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
http://www.takempis.com
Neither a follower nor a lender be.
 
Back
Top