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. Link to comment https://forums.phpfreaks.com/topic/18490-not-sure-how-to-do-this-date/ 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 Link to comment https://forums.phpfreaks.com/topic/18490-not-sure-how-to-do-this-date/#findComment-79646 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? Link to comment https://forums.phpfreaks.com/topic/18490-not-sure-how-to-do-this-date/#findComment-79650 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. Link to comment https://forums.phpfreaks.com/topic/18490-not-sure-how-to-do-this-date/#findComment-79651 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. Link to comment https://forums.phpfreaks.com/topic/18490-not-sure-how-to-do-this-date/#findComment-79653 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.