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

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
 
K

Kevin Spencer

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,527
Members
44,998
Latest member
MarissaEub

Latest Threads

Top