I just realized that (Format(R.Date_VL,’yyyy/mm’) = Format(M.Date,’yyyy/mm’) is why my script is very slow.
Do you know why and if there is a way to avoid that syntax ?
its very very slow when I use format = format !!
Edit : I want to join on months and years not days
SQL = "SELECT M_Net_Flow.ID_Perf, M_Net_Flow.Net_Flow AS XX, laps" SQL = SQL + " INTO AAA" SQL = SQL + " FROM M_Net_Flow INNER JOIN R_Dates ON (Format(R_Dates.Date_VL,'mm/aaaa') = Format(M_Net_Flow.Date,'mm/aaaa'))" SQL = SQL + " GROUP BY M_Net_Flow.ID_Perf, M_Net_Flow.Net_Flow, laps" SQL = SQL + " HAVING (LAPS < " + deb + ");" DoCmd.RunSQL SQL
Advertisement
Answer
You could also try using DateDiff:
SQL = "SELECT M_Net_Flow.ID_Perf, M_Net_Flow.Net_Flow AS XX, Laps " SQL = SQL + "INTO AAA " SQL = SQL + "FROM M_Net_Flow, R_Dates " SQL = SQL + "WHERE DateDiff("m", R_Dates.Date_VL, M_Net_Flow.Date) = 0 " SQL = SQL + "GROUP BY M_Net_Flow.ID_Perf, M_Net_Flow.Net_Flow, laps " SQL = SQL + "HAVING Laps < " + deb + ";"