Results 1 to 6 of 6
  1. #1
    Seckert is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Apr 2009
    Posts
    4

    Joining SQL Date field to SQL DateTime field

    I'm using Access to operate on data from several different SQL dbs / developers. After a laptop crash and replacement, the new version of Access is giving me a "Type mismatch in expression" error, which I have traced to joining a DATE field to a DATETIME; the DATE field reflects as "Short Text" in the linked table. (I remember this was problematic in the past, but I thought they fixed the issue.) I know it's possible, as I've been using this proc for over a year, but I can't figure out what I did to make it work. Is there a patch or setting that will allow Access to treat these as the same and allow me to join on them?



    Thanks

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    Perhaps use CDate() function on the DATE field. Then try building the JOIN in SQL View because can't use Design View.

    SELECT table1.*, table2.* FROM table1 INNER JOIN table2 ON CDate(Table1.DATEFIELD) = Table2.DATETIMEFIELD;
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    Gicu's Avatar
    Gicu is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,115
    Is the field that shows up as Short Text in Access defined as DateTime in SQL server? What ODBC driver do you use? If you have access to the SQL tables try to change the field to DateTime and refresh the link and it should show up as Date in Access. If not I think you should create a query using CDate() to convert it into a Date field then join on that (you might have a better performance than using the CDate in the Join directly).

    Cheers,
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

  4. #4
    Seckert is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Apr 2009
    Posts
    4
    Thanks for the replies.

  5. #5
    Seckert is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Apr 2009
    Posts
    4
    Yup - it was the Driver. All good - thanks!

  6. #6
    Gicu's Avatar
    Gicu is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,115
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 5
    Last Post: 01-19-2021, 04:53 AM
  2. How to extract date from a datetime text field?
    By stalk in forum Programming
    Replies: 5
    Last Post: 01-18-2017, 12:06 PM
  3. Replies: 1
    Last Post: 08-15-2016, 10:29 PM
  4. Replies: 2
    Last Post: 07-20-2015, 07:51 PM
  5. Help with datetime field in subform
    By Delta729 in forum Access
    Replies: 3
    Last Post: 04-07-2015, 04:47 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums