Inline Date Variables in Model Builder

Discussion created by PHolleran-esristaff Employee on Mar 21, 2011
Latest reply on May 22, 2014 by pml
I am attempting to use two date variables as sql query parameters in the select features tool.  My data is stored in an Access personal geodatabase and dates are in #mm-dd-yy hh:mm:ss# format.

I have defined two date variables in model builder, FromDate and ToDate, and have defined them as model parameters.  I am looking to select from features WHERE: %FromDate% <= [DateField]<= %ToDate%.

The only problem is that no matter what syntax I try I end up with either a data type mismatch error and/or no records returned.

I have tried:
- "%FromDate% <= [DateField] <= %ToDate%"
- "#%FromDate%# <= [DateField] <= #%ToDate%#"
- "#&'%FromDate%'&# <= [DateField] <= #&'%ToDate%'&#"
and other combinations to no avail.

I can successfully select records when actual '#dd:mm:yy#' are passed, just not variable values.

Can anyone provide some insight on how to pass Access-friendly inline date variables through a sql query?

- Phil H