hostfreak Posted August 24, 2006 Share Posted August 24, 2006 I've got a date field (hiredate) in my database (0000-00-00) for employees. What I want to do is get the results for the employees that have been working more than four years. Any help is appreciated and thanks in advance. Quote Link to comment Share on other sites More sharing options...
AndyB Posted August 24, 2006 Share Posted August 24, 2006 http://www.phpfreaks.com/quickcode/Comparing_Dates_Using_PHP_and_MySQL/40.php Quote Link to comment Share on other sites More sharing options...
hostfreak Posted August 24, 2006 Author Share Posted August 24, 2006 Thanks Andy, but I am not quit sure that is what I need. I only need to display employees that have been there 4 or more years. Hmm... I am not really sure how to go about explaining it. I guess I was hoping there was a way do do it just in the query and then loop through the results? Quote Link to comment Share on other sites More sharing options...
hostfreak Posted August 24, 2006 Author Share Posted August 24, 2006 I think I got it with:[code]DATE_SUB(CURDATE(),INTERVAL 1460 DAY) <= hiredate[/code]Not sure though, checking now.edit- Alright, it works. Thanks. Quote Link to comment Share on other sites More sharing options...
AndyB Posted August 24, 2006 Share Posted August 24, 2006 Yeah, sorry if my response was a little cryptic. Glad you solved it. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.