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
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

Link to comment
Share on other sites

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

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.