Results 1 to 6 of 6

sss

  1. #1
    shabar is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Jan 2013
    Posts
    66

    sss

    Hi All


    When I run below query I get Type mismatch in expression error. Both columns in date type




    Select * from T1 where
    T1.DateAsAt = (SELECT MAX(T2.DateAsAt) FROM T2)




    Please clarify




    Cheers


    shabar

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,626
    Can't see anything wrong with that SQL. I tested that syntax and it works for me.

    Are T1 and T2 tables or queries?

    If you want to provide db for analysis, follow instructions at bottom of my post.
    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
    alcapps is offline Competent Performer
    Windows 8 Access 2010 32bit
    Join Date
    Jan 2012
    Posts
    292
    Select * from T1 where
    T1.DateAsAt = (SELECT MAX(T2.DateAsAt) FROM T2)

    for me you need to add T1 after from on the sub query to work..


    Select * from T1 where
    T1.DateAsAt = (SELECT MAX(T2.DateAsAt) FROM T1 as T2)

    this worked for me

  4. #4
    alcapps is offline Competent Performer
    Windows 8 Access 2010 32bit
    Join Date
    Jan 2012
    Posts
    292
    Select *, (SELECT MAX(T2.DateAsAt) FROM T1 as T2) as Maxdate from T1
    use this if you want the max date and all the values in your Table as well.

    just playing around with the query..

  5. #5
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,626
    SELECT * FROM T1 WHERE T1.DateAsAt = (SELECT Max(DateAsAt) FROM T2);

    This assumes there are two objects (tables or queries) named T1 and T2.
    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.

  6. #6
    shabar is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Jan 2013
    Posts
    66
    Thax All

    I had a issue with two fields

    Appreciate your response



    Cheers

    Shabar

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

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