Hello all,
I am trying to automate an email for our company that will alert upper management of upcoming employment anniversary dates. I am stuck on my query. The field “hire_date” is a date field (not datetime or timestamp). I would like for my query to search the “hire_date” field for any anniversary dates within 14 days.
I have done some research and understand that the “date” field type may not best be suited for this type of query. Therefore, I have two questions:
1. What repercussions will I experience should I change the field type (which field type would you recommend)?2. If this query CAN be done with the current field type, how would I go about doing this?
My attempt at this query is:
[code=php]“SELECT * FROM pto.employees WHERE hire_date BETWEEN NOW() AND DATE_ADD(NOW(), INTERVAL 7 DAY)”)
Of course, this doesn’t work as the date field includes the year, which this query takes into account.
The database I am using is already in use on another project, so I’d like to minimize any risk associated with changing the field type.
Thank you in advance for your help.