Jump to content

Need help with a DATE issue


xwishmasterx

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?

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.