excel - Write an SQL query selecting data from filtered Date columns -
i trying query crosstab table/recordset in access (tried ado on excel sheet), columns having dates in them e.g.
if want pull limited data having columns year 2014, how write such query? please note, these columns may vary.
something this, there may simpler method though
sub akward_query() dim strsql string dim strsql2 string dim rst adodb.recordset dim fld adodb.field dim intyear integer intyear = 2014 strsql = "select top 1 * tbl_test" set rst = new adodb.recordset rst.open strsql, currentproject.connection, 1 strsql2 = "select " each fld in rst.fields if instr(1, fld.name, "week ending") > 0 , instr(1, fld.name, intyear)>0 strsql2 = strsql2 & "[" & fld.name & "]," end if next fld if right(strsql2, 1) = "," strsql2 = left(strsql2, len(strsql2) - 1) strsql2 = strsql2 & " tbl_test" end sub
Comments
Post a Comment