Results 1 to 3 of 3
  1. #1
    3 Star Lounger
    Join Date
    Sep 2001
    Location
    Stuck at work..., Missouri, USA
    Posts
    248
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Most recent date from list (2003 SP2)

    I have been using the following code to get either the most recent date or the word Never from a table that indicates whether an action took place or not with an employee. If it took place, they have 1 to many records. If it has not, they have no records.

    max(nz(Format([MonitorDateTime],"mm/dd/yyyy"),"Never"))

    After the first of the year, it stopped working. I'm getting mostly dates from last year.

    Ummm...I'm confused. Isn't 01/01/2008 > 12/31/2007??

    How can I fix this?

    Thanks!
    <font face="Comic Sans MS">Morgan Erickson</font face=comic>
    morgan.erickson@sprint.com
    <img src=/S/flags/USA.gif border=0 alt=USA width=30 height=18>-From <img src=/S/flags/Colorado.gif border=0 alt=Colorado width=30 height=18> but living in <img src=/S/flags/Missouri.gif border=0 alt=Missouri width=30 height=18>...and working in Kansas.

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Most recent date from list (2003 SP2)

    The format function converts the date values to text strings, so they are sorted alphabetically. Since 1 comes after 0, 12/31/2007 is sorted after 01/01/2008.

    Try this:

    Nz(Max([MonitorDateTime]),"Never")

  3. #3
    3 Star Lounger
    Join Date
    Sep 2001
    Location
    Stuck at work..., Missouri, USA
    Posts
    248
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Most recent date from list (2003 SP2)

    I did not realize the format function did that, thank you.

    I changed it to this:
    Nz(Format(Max([MonitorDateTime]),"mm/dd/yyyy"),"Never")
    and it worked.

    Thanks so much!
    <font face="Comic Sans MS">Morgan Erickson</font face=comic>
    morgan.erickson@sprint.com
    <img src=/S/flags/USA.gif border=0 alt=USA width=30 height=18>-From <img src=/S/flags/Colorado.gif border=0 alt=Colorado width=30 height=18> but living in <img src=/S/flags/Missouri.gif border=0 alt=Missouri width=30 height=18>...and working in Kansas.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •