March 26, 2018 at 5:11 am
In my query I want to make a selection of data based on between dates.
Baecause I don't want to change the query every time, I want to set the dates in an Excel-file and use these dates as variable in my SQL.
Excel-field formatted as date : 05/02/2018
script :
declare @gromdate smalldatetime;
set @fromdate = cast(('y:\concorde\xalwin\octopus\exportverkoopoctopus-datumselectie.xlsx[Sheet1$c1]')-2 as smalldatetime);
print @fromdate
error :
Msg 245, Level 16, State 1, Line 2
Conversion failed when converting the varchar value 'y:\concorde\xalwin\octopus\exportverkoopoctopus-datumselectie.xlsx[Sheet1$c1]' to data type int.
March 26, 2018 at 6:42 am
You need to use OPENQUERY or a linked server or SSIS or something like that to grab the data from Excel. What you're trying to do is convert the actual file path to a date, which clearly isn't going to work. Why don't you store the date in the database instead of in Excel?
John
Viewing 2 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply
This website stores cookies on your computer.
These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media.
To find out more about the cookies we use, see our Privacy Policy