Jump to content

Recommended Posts

I have 2 tables which both contains timestamp (same format). I am trying to do a count from one of the tables and need to do the count where the DATES are the same I have tried this:

 

WHERE DATE(teamwar_info.war_started) = DATE(vtp_tracking.action_date)

 

I am getting a result, but not the right one.

 

If I do like this:

 

DATE(teamwar_info.war_started) = curdate() 

 

It counts all values found.

 

How do I do a count where the date for teamwar_info.war_started and vtp_tracking.action_date are the same?

Link to comment
https://forums.phpfreaks.com/topic/235218-need-help-with-a-date-issue/
Share on other sites

Thanks pikachu2000 that did the trick with just getting the date.

Unfortunately this did help me as I thought. Goin back to previous post I still need:

 

WHERE DATE(teamwar_info.war_started) = DATE(vtp_tracking.action_date)

 

Is there a way I can combine them? I am amazed how difficult it is to just compare to timestamps...

ok here is the code I would like to get to work first:

 

$sql_teamwarinfo = "SELECT count(vtp_tracking.teamid), vtp_tracking.action_date, teamwar_info.war_started
FROM vtp_tracking, teamwar_info
WHERE vtp_tracking.teamid=".$members_teamid." AND teamwar_info.war_started < vtp_tracking.action_date";
$rs_teamwarinfo = mysql_query( $sql_teamwarinfo );
$row_teamwarinfo = mysql_fetch_array($rs_teamwarinfo);

 

This part is the problem : "teamwar_info.war_started < vtp_tracking.action_date"

 

I want to count ONLY where the date is AFTER "teamwar_info.war_started"

(in the end I want to count the between the date of "teamwar_info.war_started" and 2 days ahead)

 

I tried doing as you posted earlier (DATE ...) AS atc_date, but that only returns the first date..

 

Any ideas?

Any ideas?

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.