Jump to content


Photo

Not sure how to do this (date)


  • Please log in to reply
4 replies to this topic

#1 hostfreak

hostfreak
  • Members
  • PipPipPip
  • Advanced Member
  • 581 posts

Posted 24 August 2006 - 01:36 AM

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.

#2 AndyB

AndyB
  • Staff Alumni
  • Advanced Member
  • 5,465 posts
  • LocationToronto

Posted 24 August 2006 - 01:40 AM

http://www.phpfreaks...nd_MySQL/40.php
Legend has it that reading the manual never killed anyone.
My site

#3 hostfreak

hostfreak
  • Members
  • PipPipPip
  • Advanced Member
  • 581 posts

Posted 24 August 2006 - 02:09 AM

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?

#4 hostfreak

hostfreak
  • Members
  • PipPipPip
  • Advanced Member
  • 581 posts

Posted 24 August 2006 - 02:13 AM

I think I got it with:

DATE_SUB(CURDATE(),INTERVAL 1460 DAY) <= hiredate

Not sure though, checking now.

edit- Alright, it works. Thanks.

#5 AndyB

AndyB
  • Staff Alumni
  • Advanced Member
  • 5,465 posts
  • LocationToronto

Posted 24 August 2006 - 02:25 AM

Yeah, sorry if my response was a little cryptic. Glad you solved it.
Legend has it that reading the manual never killed anyone.
My site




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users