I'm haveing a table with a birthday, stored as 12.11 for the 12th of november .
I'm trying to make a query, to select only records with a birthday between dates d1 and d2, but Access always tells me that the query is too complex to evaluate.
Sometimes, I succeed in retrieving the query, but when I then close and reopen access, again, the query is too complex.
Can anyone advise me on how to solve this ?
This is my query :
SELECT * FROM addresses
WHERE (((CDate(d1))<=DateSerial(Year(Now()),Val(Mid$([addresses].[birthday],InStr([addresses].[birthday],"."+1)),Val(Left$([addresses].[birthday],InStr([addresses].[birthday],"."-1)))) And ((DateSerial(Year(Now()),Val(Mid$([addresses].[birthday],InStr([addresses].[birthday],"."+1)),Val(Left$([addresses].[birthday],InStr([addresses].[birthday],"."-1))))<=CDate(d2))) Or (((CDate(d1))<=DateSerial(Year(Now())+1,Val(Mid$([addresses].[birthday],InStr([addresses].[birthday],"."+1)),Val(Left$([addresses].[birthday],InStr([addresses].[birthday],"."-1)))) And ((DateSerial(Year(Now())+1,Val(Mid$([addresses].[birthday],InStr([addresses].[birthday],"."+1)),Val(Left$([addresses].[birthday],InStr([addresses].[birthday],"."-1))))<=CDate([Forms]![members]![d2])))
(Get the day and month out of the birthday, and compare if this years birthday between d1 and d2, or if next years birthday between d1 and d2)
I'm trying to make a query, to select only records with a birthday between dates d1 and d2, but Access always tells me that the query is too complex to evaluate.
Sometimes, I succeed in retrieving the query, but when I then close and reopen access, again, the query is too complex.
Can anyone advise me on how to solve this ?
This is my query :
SELECT * FROM addresses
WHERE (((CDate(d1))<=DateSerial(Year(Now()),Val(Mid$([addresses].[birthday],InStr([addresses].[birthday],"."+1)),Val(Left$([addresses].[birthday],InStr([addresses].[birthday],"."-1)))) And ((DateSerial(Year(Now()),Val(Mid$([addresses].[birthday],InStr([addresses].[birthday],"."+1)),Val(Left$([addresses].[birthday],InStr([addresses].[birthday],"."-1))))<=CDate(d2))) Or (((CDate(d1))<=DateSerial(Year(Now())+1,Val(Mid$([addresses].[birthday],InStr([addresses].[birthday],"."+1)),Val(Left$([addresses].[birthday],InStr([addresses].[birthday],"."-1)))) And ((DateSerial(Year(Now())+1,Val(Mid$([addresses].[birthday],InStr([addresses].[birthday],"."+1)),Val(Left$([addresses].[birthday],InStr([addresses].[birthday],"."-1))))<=CDate([Forms]![members]![d2])))
(Get the day and month out of the birthday, and compare if this years birthday between d1 and d2, or if next years birthday between d1 and d2)