Jump to content

date_sub()


AV1611

Recommended Posts

//edit figured it out, but will leave up if anyone cares:
// this was the problem line:
// AND DATE_SUB(NOW(),INTERVAL 30 DAY)<=surveyresults.DATE");
//forgot the surveyresults. part

neither of these will work...

[code]
$result1 = mysql_query("Select
count( distinct surveyresults.ID)
From
surveyresults
Inner Join survey ON surveyresults.ID = survey.ID
Where
survey.INACTIVE Not Like 'YES'
AND DATE_SUB(NOW(),INTERVAL 30 DAY)<=DATE");
if ($row = mysql_fetch_array($result1)){


$result2 = mysql_query("Select
surveyresults.TEAM_LEADER,
surveyresults.FNAME,
surveyresults.LNAME,
surveyresults.ID,
Avg(surveyresults.RATING) AS RATING
From
surveyresults
Inner Join survey ON surveyresults.ID = survey.ID
Where
survey.INACTIVE Not Like 'YES'
AND DATE_SUB(NOW(),INTERVAL 30 DAY)<=DATE
Group By
surveyresults.ID
ORDER BY
RATING desc");
[/code]

here is my table structure:

# Table "surveyresults" DDL

CREATE TABLE `surveyresults` (
`TEAM_LEADER` varchar(255) NOT NULL default '',
`FNAME` varchar(255) NOT NULL default '',
`LNAME` varchar(255) NOT NULL default '',
`ID` varchar(255) NOT NULL default '',
`RATING` varchar(255) NOT NULL default '',
`EVALUATOR` varchar(255) NOT NULL default '',
`DATE` date NOT NULL default '0000-00-00',
`IP` varchar(255) NOT NULL default '',
`HOSTNAME` varchar(255) NOT NULL default '',
`REMARKS` text NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COMMENT='InnoDB free: 13312 kB; InnoDB free: 13312 kB; InnoDB free: 1'
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.