Jump to content

COUNT from one date to another


JasonORDSW

Recommended Posts

I am running a members profile ssytem.. and I am trying to get a page to display the total of NEW members since a individual last logged on.

 

My current code is:

 

$query_newmembers = mysql_query("SELECT COUNT(*) FROM members WHERE TO_DAYS(stamp_approved)-TO_DAYS(\'$stamp_lastlogin2\')>0 AND status=\'A\' AND level IN (2,3,4)");

 

however it does not seem to be displaying the PROPER number of new members since a person last logged on (lastlogin2)

 

Can anyone help?

 

Thanks!

 

Jason[/code]

Link to comment
https://forums.phpfreaks.com/topic/1085-count-from-one-date-to-another/
Share on other sites

If you have the filed type as time stamp you may need to extract the date alone used

 

SELECT COUNT(*) FROM members WHERE TO_DAYS(substring(<field_name>,1,11)) -TO_DAYS(\'$stamp_lastlogin2\') )>0 AND status=\'A\' AND level IN (2,3,4)"); 

 

ensure that \"$stamp_lastlogin2\" is in date format YYYY-MM-DD

Both the stamp approved and the lastlogin2 are datetime fields.. I wanted to kep it this way.. so it has a more ACCURATE reporting for when you do certain functions on the site.

 

Looks like I will have to extract the date ONLY for both fields.. THANKS for your help!

 

Any other suggestions.. please pass them along!

 

Jason

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.