troubleshooting Question

Using Date Parameters with a SQL Stored Procedure in Excel

Avatar of FMabey
FMabeyFlag for United Kingdom of Great Britain and Northern Ireland asked on
Microsoft SQL ServerSQL
2 Comments1 Solution84 ViewsLast Modified:
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'

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 & "'

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
ASKER CERTIFIED SOLUTION
FMabey
FMabey

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 2 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 2 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros