CanMan2004 Posted December 27, 2006 Share Posted December 27, 2006 Hi allHope 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 isID TITLE TIME DATE1 Test 1 12:32:01 2006-12-232 Test 2 14:21:34 2006-12-243 Test 3 23:11:09 2006-12-264 Test 4 05:22:54 2006-12-27I store the date in the following formatYYYY-MM-DDand time in the following formatHH:MM:SSI 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 isID NAME LOGTIME LOGDATE1 Dave 15:23:23 2006-12-232 John 09:02:34 2006-12-243 Shelly 11:19:57 2006-12-26Basically, 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-264 Test 4 05:22:54 2006-12-27It would then return a number 2 as that is the total rows found.Is this easy to do? Any help or advice would be greatThanks in advanceEd Quote Link to comment Share on other sites More sharing options...
bljepp69 Posted December 27, 2006 Share Posted December 27, 2006 I think this will work:[code]SELECT * FROM table WHERE logged_date >= '$shellys_log_date' && logged_time >= '$shellys_log_time'[/code]mySQL has very good date/time handling capabilities Quote Link to comment Share on other sites More sharing options...
CanMan2004 Posted December 27, 2006 Author Share Posted December 27, 2006 thank you Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.