Querying InSQL from Excel

T

Thread Starter

tsflstb

I am trying to create an Excel file using the "get external data" via MS Query to acquire plant data from a server running InSQL. The query works with most parameters except for the date. I've had no luck in trying to query between two dates, or even querying for an exact date. I think there may be some issues with the date format Excel uses versus InSQL. Has anyone run across this problem before? Thanks.
 
P

Piotr Kowalski

I used to build a SQL query in VBA. For example:

sqlstring = sqlstring & "SET wwEndDate '" & frmRange.txtDate & " 6:30am' "

where frmRange.txtDate is a date string in the form "mm-dd-yy"
After the the SQL query string is complete, I do:

"connstring = _
"ODBC;DSN=SQL;UID=wwUser;PWD=wwUser;APP=MicrosoftR Query;WSID=JAN
SKOWKA;DATABASE="
With ActiveSheet.QueryTables.Add(Connection:=connstring, _
Destination:=Sheets(2).Range("C10"), Sql:=sqlstring)
.Refresh
End With"


Regards,
Piotr Kowalski
 
I have a cell(a1) as 12/01/2007 to be used as a paramter in sqlsgtring. Can you please let me know how it shoud be written??

Thanks,
ragup
 
Top