Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3397220
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T04:30:08+00:00 2026-05-18T04:30:08+00:00

Here’s the query that is being executed on SQL Server 2008: SELECT "dbo"."tblMainData"."recID" FROM

  • 0

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:

  1. Call stored procedures from Access. I’m not sure how to do this yet.
  2. Update the data in the sql server database with a date that wont be discarded on TSQL generation.
  3. Try to find a way to make the generated TSQL include the explicit 12/30/1899 date. IDEAL

Any other ideas?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T04:30:09+00:00Added an answer on May 18, 2026 at 4:30 am

    You can change your where clause to the following which removes the date on the left side of the comparison

    WHERE TimeValue(tblMainData.timeInMain) Between #12/30/1899 9:0:0# And #12/30/1899 17:0:0#

    If you know that all values in the database will be on 12/30/1899 than you can just do

    WHERE tblMainData.timeInMain Between #12/30/1899 9:0:0# And #12/30/1899 17:0:0#

    As an aside if you want to do this in SQL Server Procedure you can strip the date using the following (its not much slower than if you knew the dates)

        WHERE 
             DATEADD( DAY , -1 *DATEDIFF(DAY, 0, timeInMain ) , timeInMain )
                        BETWEEN '09:00' and '17:00'
    

    UPDATE

    Here’s how I tested it

    I created a table and populated it using the following in SQL Server

    CREATE Test 
    ( 
        id int identity,
        DateTimeValue DateTime
    )
    
    --Values with COM Zero Date
    INSERT INTO Test (DateTimeValue) VALUES ('1/1/1899 8:00 AM')
    INSERT INTO Test (DateTimeValue) VALUES ('1/1/1899 9:00 AM')
    INSERT INTO Test (DateTimeValue) VALUES ('1/1/1899 10:00 AM')
    INSERT INTO Test (DateTimeValue) VALUES ('1/1/1899 11:00 AM')
    INSERT INTO Test (DateTimeValue) VALUES ('1/1/1899 12:00 PM')
    INSERT INTO Test (DateTimeValue) VALUES ('1/1/1899 1:00 PM')
    INSERT INTO Test (DateTimeValue) VALUES ('1/1/1899 2:00 PM')
    INSERT INTO Test (DateTimeValue) VALUES ('1/1/1899 3:00 PM')
    INSERT INTO Test (DateTimeValue) VALUES ('1/1/1899 4:00 PM')
    INSERT INTO Test (DateTimeValue) VALUES ('1/1/1899 5:00 PM')
    INSERT INTO Test (DateTimeValue) VALUES ('1/1/1899 6:00 PM')
    INSERT INTO Test (DateTimeValue) VALUES ('1/1/1899 7:00 PM')
    
    --Values with SQL Zero Date
    INSERT INTO Test (DateTimeValue) VALUES ('1/1/1900 8:00 AM')
    INSERT INTO Test (DateTimeValue) VALUES ('1/1/1900 9:00 AM')
    INSERT INTO Test (DateTimeValue) VALUES ('1/1/1900 10:00 AM')
    INSERT INTO Test (DateTimeValue) VALUES ('1/1/1900 11:00 AM')
    INSERT INTO Test (DateTimeValue) VALUES ('1/1/1900 12:00 PM')
    INSERT INTO Test (DateTimeValue) VALUES ('1/1/1900 1:00 PM')
    INSERT INTO Test (DateTimeValue) VALUES ('1/1/1900 2:00 PM')
    INSERT INTO Test (DateTimeValue) VALUES ('1/1/1900 3:00 PM')
    INSERT INTO Test (DateTimeValue) VALUES ('1/1/1900 4:00 PM')
    INSERT INTO Test (DateTimeValue) VALUES ('1/1/1900 5:00 PM')
    INSERT INTO Test (DateTimeValue) VALUES ('1/1/1900 6:00 PM')
    INSERT INTO Test (DateTimeValue) VALUES ('1/1/1900 7:00 PM')
    
    --Abritrary Date After Zero Dates
    INSERT INTO Test (DateTimeValue) VALUES ('1/1/2010 8:00 AM')
    INSERT INTO Test (DateTimeValue) VALUES ('1/1/2010 9:00 AM')
    INSERT INTO Test (DateTimeValue) VALUES ('1/1/2010 10:00 AM')
    INSERT INTO Test (DateTimeValue) VALUES ('1/1/2010 11:00 AM')
    INSERT INTO Test (DateTimeValue) VALUES ('1/1/2010 12:00 PM')
    INSERT INTO Test (DateTimeValue) VALUES ('1/1/2010 1:00 PM')
    INSERT INTO Test (DateTimeValue) VALUES ('1/1/2010 2:00 PM')
    INSERT INTO Test (DateTimeValue) VALUES ('1/1/2010 3:00 PM')
    INSERT INTO Test (DateTimeValue) VALUES ('1/1/2010 4:00 PM')
    INSERT INTO Test (DateTimeValue) VALUES ('1/1/2010 5:00 PM')
    INSERT INTO Test (DateTimeValue) VALUES ('1/1/2010 6:00 PM')
    INSERT INTO Test (DateTimeValue) VALUES ('1/1/2010 7:00 PM')
    

    I created a ODBC link to this table in MS Access 2007

    And then created the following Query which results in the 27 records that have a time value between 9:00 AM and 5:00 PM

    SELECT id, DateTimeValue
    FROM dbo_Test
    WHERE TimeValue(DateTimeValue) Between #12/30/1899 9:0:0# And #12/30/1899 17:0:0#
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here is the issue I am having: I have a large query that needs
Here's an interesting problem. On a recently installed Server 2008 64bit I opened IE
Here's a basic regex technique that I've never managed to remember. Let's say I'm
Here's my scenario - I have an SSIS job that depends on another prior
Here's a coding problem for those that like this kind of thing. Let's see
Here is the scenario: I'm writing an app that will watch for any changes
Here's a problem I ran into recently. I have attributes strings of the form
Here is a simplification of my database: Table: Property Fields: ID, Address Table: Quote
Here is my code, which takes two version identifiers in the form 1, 5,
Here we go again, the old argument still arises... Would we better have a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.