Correct me if I am wrong, but I am wondering if your example is working correct in the first place. Your example shows a character conparison on date: date between ‘1-jan-2005′ and ’10-mar-2005′.
Consider these entries in your file/table/database:
If the date field is a character field, then the first 3 entries get selected, because of the fact that they are sorted in this order.
It would be a different story if your entries in the file/table/database are filled in like this:
In this case you would select: date between ‘20050101’ and ‘20050310’, which would select 6 entries. If your routine builds the dates like this, then the dynamic selection will work.