Results 1 to 2 of 2
  1. #1
    EHittner is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Nov 2009
    Posts
    32

    Latest Date Between Separate Columns in the Same Table


    I'm trying to get a result -- in a new column -- that displays the latest date between three date fields in a single table, using the query builder. In the query builder, I entered the following...

    LatestDate: MAX([Bios Received], [ASC_Appt_Date1], [ASC_Appt_Date2])

    Before being able to run it, I'm getting the following error: "The expression you entered has a function containing the wrong number of arguments."

    I'm thinking this is probably a very simple oversight -- but I'm not seeing it. Any help is greatly appreciated.

  2. #2
    Gicu's Avatar
    Gicu is offline VIP
    Windows 10 Access 2013 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,114
    You cannot use MAX like that (it is meant to return the max value within one field). I suggest you add these two functions in a standard module:
    Code:
    Public Function Min2(a As Variant, b As Variant) As Variant
    '
    ' Returns the lesser of 2 values
    '
      Min2 = IIf(a < b, a, b)
    End Function
    Public Function Max2(a As Variant, b As Variant) As Variant
    '
    ' Returns the greater of 2 values
    '
      Max2 = IIf(a > b, a, b)
    End Function
    Once you do that your expression would be:
    LatestDate: Max2([Bios Received], Max2([ASC_Appt_Date1], [ASC_Appt_Date2]))

    If any of the three dates are missing you need to use the Nz() function to return an alternate value (such as today's date or whatever your business needs require).
    Cheers,
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

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

Similar Threads

  1. Replies: 2
    Last Post: 08-12-2019, 08:41 PM
  2. Adding query run date to a separate table
    By Maverick28 in forum Queries
    Replies: 2
    Last Post: 11-06-2017, 09:18 AM
  3. Replies: 3
    Last Post: 01-06-2016, 07:42 PM
  4. Replies: 1
    Last Post: 01-09-2015, 05:15 PM
  5. Replies: 61
    Last Post: 03-14-2011, 03:29 AM

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