View Full Version : DATEDIFF function

01-11-2012, 04:50 PM
Hi Guys, Im a bit stuck basically I have a table of peoples crb checks and when they expire and I want to show the number of days until they expire the problem is the table also holds records of crbs which have expired and I want to disregard them.

SELECT Manager.ManagerID, CONCAT(Manager.FName, ' ', Manager.LName) As Full_Name, DateDiff(CURDATE(), CRBCheck.CRBFinishDate) As RenewalIn
FROM Manager INNER JOIN CRBCheck ON Manager.ManagerID = CRBCheck.ManagerID

This sort of works at the moment it displays this:

ManagerID Full_Name RenewalIn
1 Name 219
1 Name -512
2 Name -158
3 Name 282

I need to remove the ones in the minus as they have expired

Hope someone can help

Thanks in advance

01-11-2012, 04:57 PM
just add that check in a WHERE clause:

DateDiff(CURDATE(), CRBCheck.CRBFinishDate) > 0