Notice I took the SQL FORMAT command out because you actually crafting a SQL query with a literal date (the variable "vardate" is a VBScript variable, not a SQL variable). I inserted the VBScript DateFormat command to return a short date string that SQL Server will understand and I surrounded the date with single-quotes to tell SQL this is a literal value.