Jump to content

date & time counting


CanMan2004

Recommended Posts

Hi all

Hope eveyone has a good xmas.

Can anyone help me? I have a table called "mydata", inside this table I have lots of rows, each row has a date and time assigned to it, an example is

ID  TITLE    TIME          DATE
1    Test 1    12:32:01    2006-12-23
2    Test 2    14:21:34    2006-12-24
3    Test 3    23:11:09    2006-12-26
4    Test 4    05:22:54    2006-12-27

I store the date in the following format

YYYY-MM-DD

and time in the following format

HH:MM:SS

I then have another table called "users", it contains a list of users and the last time and date they logged in to the website, an example of this table is

ID  NAME    LOGTIME          LOGDATE
1    Dave      15:23:23        2006-12-23
2    John      09:02:34        2006-12-24
3    Shelly    11:19:57        2006-12-26

Basically, when they log in, I store a session called "logtime" and another called "logdate", then, I write into the database, the current time and date, so the sessions "logtime" and "logdate" hold the date and time from the last time they log in, as the current date and time is updated after the session data is created.

So what I want to do is to count the total number of rows in table "mydata", which were added after the time and date that is stored in the session.

If I logged in as "Shelly", her logtime is 11:19:57 and her logdate is 2006-12-26, so it would return the total number of rows in "mydata" which contain a date and time which is greater than the ones stored in the sessions, for Shelly, rows 3 and 4 would be found, as they contain the following time and dates;

3    Test 3    23:11:09    2006-12-26
4    Test 4    05:22:54    2006-12-27

It would then return a number 2 as that is the total rows found.

Is this easy to do? Any help or advice would be great

Thanks in advance

Ed
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.