Results 1 to 4 of 4

Thread: getting the most current date field

  1. #1

    Thread Starter
    Fanatic Member VBKNIGHT's Avatar
    Join Date
    Oct 2000
    Location
    Port25
    Posts
    619

    getting the most current date field

    SQL 2005 Server.

    how can I get most current date in a group of date fields?

    e.x i have field1,field2,field3,field4 which is a date field how can i get the most current of the field?

    any suggestion? TIA
    Last edited by VBKNIGHT; Jun 3rd, 2007 at 08:00 PM.

    If a post has helped you then Please Rate it!

  2. #2

  3. #3
    MS SQL Powerposter szlamany's Avatar
    Join Date
    Mar 2004
    Location
    Connecticut
    Posts
    18,263

    Re: getting the most current date field

    Many, many ways to accomplish this I'm sure...

    This will work:

    Code:
    Select Max(X1.DateField)
        From (Select Max(Field1) "DateField" From SomeTable
                 Union All
                Select Max(Field2) From SomeTable
                 Union All
                Select Max(Field3) From SomeTable
                 Union All
                Select Max(Field4) From SomeTable) "X1"

    *** Read the sticky in the DB forum about how to get your question answered quickly!! ***

    Please remember to rate posts! Rate any post you find helpful - even in old threads! Use the link to the left - "Rate this Post".

    Some Informative Links:
    [ SQL Rules to Live By ] [ Reserved SQL keywords ] [ When to use INDEX HINTS! ] [ Passing Multi-item Parameters to STORED PROCEDURES ]
    [ Solution to non-domain Windows Authentication ] [ Crazy things we do to shrink log files ] [ SQL 2005 Features ] [ Loading Pictures from DB ]

    MS MVP 2006, 2007, 2008

  4. #4

    Thread Starter
    Fanatic Member VBKNIGHT's Avatar
    Join Date
    Oct 2000
    Location
    Port25
    Posts
    619

    Re: getting the most current date field

    thanks all. yes i do get the most current date now thanks

    If a post has helped you then Please Rate it!

Posting Permissions

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



Click Here to Expand Forum to Full Width