+ 0 Votes If you have fixed it, and it runs, then why change it? Peconet Tietokoneet 4 years ago You have just solved it, so why change it? + 0 Votes Thank you dilumd 4 years ago Thank you very much to all the replies + 0 Votes Use Format() hineses 4 years ago Use the Format function on your date value e.g., format(dtOSdt, "yyyy-mm-dd"). + 0 Votes Make the date format non ambigious darryl.muller 4 years ago Because you do not control the computers settings that an application is installed on, I always ensure that the date is not ambigious, so I would do the following stgrnmain.grndt >= convert(datetime, '" & format(dtOSdt, "dd mmm yyyy") & "') No matter what settings are on the computer or the SQL server it always interprets dd mmm yyyy correctly. + 0 Votes Another way of formatting date azeemsiddiqui 4 years ago You can use VB Format() function as following: Replace following part of your SQL And ((stgrnmain.grndt >= '" & dtOSdt & "') and (stgrnmain.grndt <= '" & dtOEdt & "')))", with And ((stgrnmain.grndt >= '" & Format(dtOSdt, "yyyy-MM-dd") & "') and (stgrnmain.grndt <= '" & Format(dtOEdt, "yyyy-MM-dd") & "')))", I hope it will also help. + 0 Votes error message aikimark 4 years ago Depending on your runtime environment, I think your original error message was caused by incorrect delimiters. For date literals, you need to use date delimiters. Example And (stgrnmain.grndt Between #" & dtOSdt & "# And #" & dtOEdt & "#)" Note: I changed the comparison to Between for (usually) better performance.