Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Nov 2007
    Posts
    42
    Thanks
    3
    Thanked 0 Times in 0 Posts

    DATEDIFF function

    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.

    Code:
    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

  • #2
    Super Moderator guelphdad's Avatar
    Join Date
    Mar 2006
    Location
    St. Catharines, Ontario Canada
    Posts
    2,634
    Thanks
    4
    Thanked 148 Times in 139 Posts
    just add that check in a WHERE clause:

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


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •