VBA variable in SQL date query -


i'm trying query sql database lines date after date given through user input. i've run variety of errors "incorrect syntax near" when surround date "#" "arithmetic overflow error converting expression to". current code looks this:

inputdate = inputbox("please enter starting date (mm/dd/yyyy)") debug.print inputdate  querydate = "(dtg > " & format(inputdate, "mmddyyyy") & ")"  select stationid, dtg, ceilingfeet surfaceob " & querydate & " , stationid = 'nzwd'" 

dtg column name date-time group in sql database. idea going wrong? i've tried every solution find on past few days without luck. thank in advance.

the primary issue dates must enclosed in single-quotes. here complete working example (minus valid connection string) should explain how achieve objective. note want switch iso date format, in order year-month-day (yyyy-mm-dd).

sub updaterecords()     dim connection new adodb.connection     dim recordset new adodb.recordset     dim connectionstring string     dim query string     dim inputdate date     dim querydate string      inputdate = inputbox("please enter starting date (mm/dd/yyyy)")     querydate = "(dtg > '" & format(inputdate, "yyyy-mm-dd") & "')"     query = "select stationid, dtg, ceilingfeet surfaceob " & querydate & " , stationid = 'nzwd'"      connectionstring = "..."             connection.open connectionstring     recordset.open query, connection     activesheet.range("a1").copyfromrecordset recordset end sub 

Comments

Popular posts from this blog

yii2 - Yii 2 Running a Cron in the basic template -

asp.net - 'System.Web.HttpContext' does not contain a definition for 'GetOwinContext' Mystery -

mercurial graft feature, can it copy? -