...

View Full Version : DATEDIFF function



Hayes
01-11-2012, 03: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
Danny

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



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



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum