dharkangel
MIS
Hi,
I wrote this seemingly simple query below that only gives me the correct data when I hardcode the dates like below (1/2/2006 and 1/9/2006). Whenever I substitute these dates with a variable I get errors or bad data.
strSQL = " SELECT TokyoInternalActions.[Issue ID]" & _
"FROM TokyoInternalActions INNER JOIN TokyoOGCommitDate ON TokyoInternalActions.[Issue ID]=TokyoOGCommitDate.[Issue ID]" & _
"WHERE TokyoInternalActions.Status=""Closed"" And DateValue(TokyoInternalActions.[Close Date])<=DateValue(TokyoOGCommitDate.[Original Commit Date]) And (DateValue(TokyoInternalActions.[Close Date])>=DateValue(""1/2/2006"") And DateValue(TokyoInternalActions.[Close Date])<DateValue(""1/9/2006""))"
myRecordSet.Open strSQL, , adOpenStatic
etc...............
I have tried doing the following but none work:
Dim beginningDate As String
Dim endingDate As String
beginningDate = "1/2/2006"
endingDate = "1/9/2006"
and use these variables in my query like this DateValue(beginningDate)...What am I doing wrong?
I wrote this seemingly simple query below that only gives me the correct data when I hardcode the dates like below (1/2/2006 and 1/9/2006). Whenever I substitute these dates with a variable I get errors or bad data.
strSQL = " SELECT TokyoInternalActions.[Issue ID]" & _
"FROM TokyoInternalActions INNER JOIN TokyoOGCommitDate ON TokyoInternalActions.[Issue ID]=TokyoOGCommitDate.[Issue ID]" & _
"WHERE TokyoInternalActions.Status=""Closed"" And DateValue(TokyoInternalActions.[Close Date])<=DateValue(TokyoOGCommitDate.[Original Commit Date]) And (DateValue(TokyoInternalActions.[Close Date])>=DateValue(""1/2/2006"") And DateValue(TokyoInternalActions.[Close Date])<DateValue(""1/9/2006""))"
myRecordSet.Open strSQL, , adOpenStatic
etc...............
I have tried doing the following but none work:
Dim beginningDate As String
Dim endingDate As String
beginningDate = "1/2/2006"
endingDate = "1/9/2006"
and use these variables in my query like this DateValue(beginningDate)...What am I doing wrong?