tektipsismyfavorite
Technical User
I have a cron job setup to run every minute and I want it to retrieve records for that minute. My query is setup like this:
SELECT *
FROM stuff
WHERE datetime >= '".$startdate."'
AND datetime <= '".$enddate."'
startdate and enddate get the current date/time and format it in the MySQL Date Format (YYYY-MM-DD HH:MM:SS).
Well, I put some sample data in the table and waited for my cron to execute, but it didn't work (it notifies me by email).
I then manually entered the data of:
SELECT *
FROM dates
WHERE date >= '2006-06-26 00:00:00'
AND date <= '2006-06-26 23:59:59'
and that worked fine. It pulled all results for 6/26/06.
But when I try:
I then manually entered the data of:
SELECT *
FROM dates
WHERE date >= '2006-06-26 11:48:00'
AND date <= '2006-06-26 11:48:59'
It doesn't get the records for the minute of 11:48. Some sample data, for example would be:
date = 2006-06-26 11:48:02 or
date = 2006-06-26 11:48:20 or
date = 2006-06-26 11:48:00
So, is there something wrong with how I'm finding the time?
My server is 2 hours off my time zone, so I even setup sample data for 2 hours before to see if that were the problem. What am I doing wrong?
SELECT *
FROM stuff
WHERE datetime >= '".$startdate."'
AND datetime <= '".$enddate."'
startdate and enddate get the current date/time and format it in the MySQL Date Format (YYYY-MM-DD HH:MM:SS).
Well, I put some sample data in the table and waited for my cron to execute, but it didn't work (it notifies me by email).
I then manually entered the data of:
SELECT *
FROM dates
WHERE date >= '2006-06-26 00:00:00'
AND date <= '2006-06-26 23:59:59'
and that worked fine. It pulled all results for 6/26/06.
But when I try:
I then manually entered the data of:
SELECT *
FROM dates
WHERE date >= '2006-06-26 11:48:00'
AND date <= '2006-06-26 11:48:59'
It doesn't get the records for the minute of 11:48. Some sample data, for example would be:
date = 2006-06-26 11:48:02 or
date = 2006-06-26 11:48:20 or
date = 2006-06-26 11:48:00
So, is there something wrong with how I'm finding the time?
My server is 2 hours off my time zone, so I even setup sample data for 2 hours before to see if that were the problem. What am I doing wrong?