Notification 11 months on

Sorry for posting so quickly after my last ask for help but unfortunately one follow the other.

I am writing a page where items have been tested they need then retesting 12months later on but i want to show what they are 11 months on so people have 30days then to do this and then resubmit to the database.

I would like to develop this further down the line where this is done automatically either via a cron job or some other mean and they are emailed. But one step at a time :slight_smile:

Is there a way i can do this with my mysqlselect statement ? Or am i starting to get outside what is deemed beginner ?

thank you again all.

Well, MySQL has a way to do this with ease.
Now I am not exactly sure how to fit it to your setup, but, here is a sample of how it works:

SELECT * FROM products where DATE_ADD(date_checked, INTERVAL 11 MONTH) < CURDATE()

So, you would have to change the “products” to your table and “date_checked” to your date field…

If you can not get it to work, check out MySQL’s help site for more details on the “DATE_ADD” function.

Hope that helps

Hi Ernie

It’s basically to show items that’s require PAT testing before the date due expires.
The team test an item enter this into the form and then the php writes to another date field when the test is due which in 99% of cases is 365 days or a year later on. But to aid the guys I want to show all items due for testing after 11 months so they can retest before the expiration. So I want to show all these until the date field is reset for another 11 months.
All makes perfect sense in my head :-/

I will give your suggestion a whirl and see how I get on.

Thank you all again.

Paul

Should work for you Paul.

When the item is tested, store the date it was tested into the database.
Then, there are many ways to test for the correct dates. Something like my untested version should work for you. You can have it test for the eleven months every time someone logs into the system. If you do that, you do not need a crone job set up. If items are assigned to one person, just check for their items whenever they log in. If items are assigned to many users, then, just do the query whenever anyone logs in.

Note that queries, these days, are quick and easy to do at login time. So, not exactly sure of your use of the user notification process or how many users log into your system, but, should not cause too much overhead to do the check at log in.

Good luck, Ernie… Also, if this is solved, let us know and we will mark it solved…

Hi Ernie.

Yes done just that. There is its own field in the database called “nexttest” (which is the +12 months) and a date filed that is also populated when the test is done so there is some comparison there. I have tried to implement your solution and no luck yet but then that’s probably me more than what you have advised.

There are only a handful of people using this so generating the results each time is no problem for me at all.

Yes i would like this marked solved please as i do believe this is the right solution for the problem at hand.

Thank you again

Paul

Great! I will mark it solved.

But, remember to debug your system. If you already have the data in the database, just run a query when the user logs in to pull and display the pending tests. Should work nicely for you. Glad I could help.

Sponsor our Newsletter | Privacy Policy | Terms of Service