I execute a simple DELETE on a table to remove old records earlier than 15 minutes ago
The date column (Scheduled) is formatted as a Date/Time and contains a date and time for each row.
dbS.Execute "DELETE Scheduled From MyTable WHERE Scheduled < DateAdd('n',-15,Now());"
This works fine for times from 00:01 am to 11:59 pm but does not remove any records when executed just past midnight if there are any entries still there from the previous day such as -
Say there are 5 records either side of midnight.
3/4/2015 11:55 pm
3/4/2015 11:58 pm
4/4/2015 0:03 am
4/4/2015 0:05 am
4/4/2015 0:10 am
If I run the query 4/4/2015 0:19 am it should remove only the first three entries - but it doesn't remove any!
It works fine around midday (am's & pm's reversed).
What am I doing wrong in my execute statement? Do I have to somehow separately consider Date and Time rather than use Now?
This is used in a bus departure sign running 24/7 but luckily it does not affect the end result because the bus has gone by then and removed from the screen anyway but it worries me that I can't find the reason.
The date column (Scheduled) is formatted as a Date/Time and contains a date and time for each row.
dbS.Execute "DELETE Scheduled From MyTable WHERE Scheduled < DateAdd('n',-15,Now());"
This works fine for times from 00:01 am to 11:59 pm but does not remove any records when executed just past midnight if there are any entries still there from the previous day such as -
Say there are 5 records either side of midnight.
3/4/2015 11:55 pm
3/4/2015 11:58 pm
4/4/2015 0:03 am
4/4/2015 0:05 am
4/4/2015 0:10 am
If I run the query 4/4/2015 0:19 am it should remove only the first three entries - but it doesn't remove any!
It works fine around midday (am's & pm's reversed).
What am I doing wrong in my execute statement? Do I have to somehow separately consider Date and Time rather than use Now?
This is used in a bus departure sign running 24/7 but luckily it does not affect the end result because the bus has gone by then and removed from the screen anyway but it worries me that I can't find the reason.