Using Dates from Cell or named Range in Sql Query

后端 未结 2 1468
被撕碎了的回忆
被撕碎了的回忆 2020-12-12 04:23

I have created a sheet to extract data from a Microsoft SQL database to produce a customer report between 2 date StartDate and EndDate.

I h

2条回答
  •  误落风尘
    2020-12-12 05:16

    Try changing the date part of your SQL statement to:

    "[...] originalAlarmTime BETWEEN '" & Format$(StartDate, "yyyy-mm-dd") & "' AND '" & Format$(EndDate, "yyyy-mm-dd") & "' [...]"
    

    You might also try using a parameterized query.

提交回复
热议问题