Jump to content

Archived

This topic is now archived and is closed to further replies.

hostfreak

Not sure how to do this (date)

Recommended Posts

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.

Share this post


Link to post
Share on other sites
http://www.phpfreaks.com/quickcode/Comparing_Dates_Using_PHP_and_MySQL/40.php

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Yeah, sorry if my response was a little cryptic. Glad you solved it.

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.