vba deletes all records and ignores where condition?

MikeL

Active Member
Joined
Mar 17, 2002
Messages
488
Office Version
  1. 365
Platform
  1. Windows
strSQL = "DELETE * From [tEST] WHERE [Pay_End_Dt] > 10/1/2020"
 

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
Interesting. Can only imagine that the date being passed is null or an empty string, which would explain it. However, I would have expected a syntax error instead.
 
Upvote 0
Interesting. Can only imagine that the date being passed is null or an empty string, which would explain it. However, I would have expected a syntax error instead.
I don't think so. I think it is doing a valid mathematical computation (just not the one you want).
10/1/2020 would read as 10 divided by 1, which would be 10, and then divided by 2020, which would be: 0.00495.
Since Excel and Access store dates as the number of days since 1/0/1900, that would be a time on that date.
So any date after 1/0/1900 wou;d evaluate as TRUE, and be returned.
 
Upvote 0
I don't think so. I think it is doing a valid mathematical computation (just not the one you want).
10/1/2020 would read as 10 divided by 1, which would be 10, and then divided by 2020, which would be: 0.00495.
Since Excel and Access store dates as the number of days since 1/0/1900, that would be a time on that date.
So any date after 1/0/1900 wou;d evaluate as TRUE, and be returned.
This seems to be working for me as I have been able to isolate records related to each quarter in a year using between ,and, > , < operators
 
Upvote 0
This seems to be working for me as I have been able to isolate records related to each quarter in a year using between ,and, > , < operators
Yes, it works properly when you use the date qualifiers of "#".
I was responding to Micron's reply, explaining the logic why it was selecting/deleting all the records when you don't use the date qualifiers (your original question).
 
Upvote 0

Forum statistics

Threads
1,221,526
Messages
6,160,340
Members
451,637
Latest member
hvp2262

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top