I am trying to join two tables on ID1, ID2 and when Date > Start AND < End but I keep getting an error when I add the date fields in. Just joining on ID1 and ID2 works fine, but I'm of course getting duplicated records because in my right table I can have two lines for ID1, ID2 with a different start and end date. I'm trying to join so I can grab a field from my right table and add it into my results.
Typically in SQL Server I would just do a join on LeftTable.ID1 = RightTable.ID1 AND LeftTable.ID2 = RightTable.ID2 AND LeftTable.Date >= RightTable.Start AND Date < RightTable.End, but I can't get that to work in Access. It's giving me a message saying I have an error in my Join expression is not supported. I know the SQL that Access supports is a little different than SQL server so if someone could help me out that would be great.
This works:
This doesn't:
Typically in SQL Server I would just do a join on LeftTable.ID1 = RightTable.ID1 AND LeftTable.ID2 = RightTable.ID2 AND LeftTable.Date >= RightTable.Start AND Date < RightTable.End, but I can't get that to work in Access. It's giving me a message saying I have an error in my Join expression is not supported. I know the SQL that Access supports is a little different than SQL server so if someone could help me out that would be great.
This works:
SQL:
FROM All_Claims LEFT JOIN tmp_Duration2 ON (All_Claims.RPID = tmp_Duration2.RPID) AND (All_Claims.PATID = tmp_Duration2.PATID)
This doesn't:
SQL:
FROM All_Claims LEFT JOIN tmp_Duration2 ON (All_Claims.RPID = tmp_Duration2.RPID) AND (All_Claims.PATID = tmp_Duration2.PATID) AND (All_Claims.[DOSDATE]>=tmp_Duration2.Rvsd_Cnt_Start_Dt) AND (All_Claims.[DOSDATE]<DateAdd("y",1,tmp_Duration2.Rvsd_Cnt_Start_Dt)