Avatar of FMabey
FMabey
Flag for United Kingdom of Great Britain and Northern Ireland

asked on 

Using Date Parameters with a SQL Stored Procedure in Excel

Hi all,

I have connection in Excel that uses a SQL Server stored procedures with two date parameters. In the connection properties I can successfully run the query with the following command in the command text:
exec SW_Maintenance_GL  '2018-09-01','2018-09-30'

Open in new window


However, when I try and replace this with the following in order to pick up two dates entered into worksheet cells:
exec SW_Maintenance_GL  '" & Range("H1").text & "','" &  Range("I1").text & "'

Open in new window


I get the following error:
Error converting data type varchar to date

The actual value in theses cells is shown as 01/09/2018 although it is formatted as 2018-09-01 and I presumed that using Range("I1").text instead of Range("I1").value would have worked??

Thanks in advance
Microsoft SQL ServerSQL

Avatar of undefined
Last Comment
FMabey

8/22/2022 - Mon