Results 1 to 7 of 7
  1. #1
    JeffChr is offline Advanced Beginner
    Windows 7 64bit Access 2010 32bit
    Join Date
    Feb 2014
    Posts
    82

    min max fuctions on a date field returning unexpected results

    I am trying to return the min date value from one field and the max from another using the following SQL

    SELECT tIHS.[VP: Production Brand], tIHS.[VP: Global Nameplate], tIHS.[T: Program], Min(tIHS.[VP: SOP (Start of Production)]) AS [MinOfVP: SOP (Start of Production)], Max(tIHS.[VP: EOP (End of Production)]) AS [MaxOfVP: EOP (End of Production)]
    FROM tIHS


    GROUP BY tIHS.[VP: Production Brand], tIHS.[VP: Global Nameplate], tIHS.[T: Program];

    SOP and EOP are date fields. I am not sure what is being returned but it's not min and max. I think it is just returning data from the first row of data rather than looking at all rows for the min and max. There are 3 qualifying rows.

    Does min and max not work with dates ? Thank you for your feedback!
    Last edited by JeffChr; 06-17-2015 at 07:32 AM. Reason: solved

  2. #2
    JoeM is offline VIP
    Windows XP Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    Are your dates stored as a Date data type in your underlying table, or as Text?

  3. #3
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    Are you trying to collect user input as a parameter? I believe this will be interpreted as text and, therefore, will not be sorted as a date.

    Perhaps there is another approach that can be taken. It will be difficult to validate the text as a valid syntax within a query. You can cast text strings to a date though. Maybe use the CDate() function.
    https://msdn.microsoft.com/en-us/lib...ectionSection3

  4. #4
    JeffChr is offline Advanced Beginner
    Windows 7 64bit Access 2010 32bit
    Join Date
    Feb 2014
    Posts
    82
    Thanks. I figured it out. Human error. The db was working fine. (One of those days!)

  5. #5
    orange's Avatar
    orange is online now Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,726

  6. #6
    JeffChr is offline Advanced Beginner
    Windows 7 64bit Access 2010 32bit
    Join Date
    Feb 2014
    Posts
    82
    Sorry, I thought I did. There was nothing to fix. I was reading the results incorrectly. Human error, ie; Me.

  7. #7
    orange's Avatar
    orange is online now Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,726
    Thanks for clarifying. I thought you may have had to "tweak" something.

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

Similar Threads

  1. Unexpected results on Inner Join
    By Access_Novice in forum Access
    Replies: 2
    Last Post: 09-05-2014, 12:50 AM
  2. Unexpected results with DAO recordset
    By GraeagleBill in forum Programming
    Replies: 1
    Last Post: 10-07-2012, 07:37 PM
  3. Unexpected Results from Curdir?
    By bginhb in forum Programming
    Replies: 6
    Last Post: 08-17-2011, 03:58 PM
  4. InStrRev returning unexpected results
    By jgelpi16 in forum Programming
    Replies: 2
    Last Post: 12-07-2010, 01:04 PM
  5. Query showing unexpected results
    By johnmerlino in forum Queries
    Replies: 30
    Last Post: 10-25-2010, 07:08 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