Here's the query that is being executed on SQL Server 2008:
SELECT "dbo"."tblMainData"."recID"
FROM "dbo"."tblMainData"
WHERE ("timeInMain" BETWEEN {t '08:00:00'} AND {t '17:00:00'} )
This query is generated by a Microsoft Access 2007 database that has linked tables in the SQL Server 2008 database.
Here is the Access query that generates the above query:
SELECT tblMainData.timeInMain
FROM tblMainData
WHERE (((tblMainData.timeInMain) Between #12/30/1899 8:0:0# And #12/30/1899 17:0:0#));
Anyway, I know that there is data that meets this criteria. Why aren't I seeing the expected results?
This is the first time I have seen the {t '08:00:00'} syntax, which I'm assuming is supposed to disregard the date portion of the datetime field. I couldn't find any documentation on it.
Thanks for any help.
UPDATE
Just ran select {t '08:00:00'} in SSMS, which returned 2010-11-17 08:00:00.000. That explains why I'm not getting data back. But, as you can see, the Access query is explicit about which date to use and the generated TSQL doesn't include it. What to do?
UPDATE 2
I have done some experimenting. Access only removes the date from generated TSQL when it is 12/30/1899. Apparently, this is a special date that access uses when a user stores only a time in a DateTime field and Access assumes that if it's included in a query, then it's not really important. Wow.
So, I believe my options are:
- Call stored procedures from Access. I'm not sure how to do this yet.
- Update the data in the sql server database with a date that wont be discarded on TSQL generation.
- Try to find a way to make the generated TSQL include the explicit 12/30/1899 date. IDEAL
Any other ideas?