Results 1 to 3 of 3
  1. #1
    Join Date
    Feb 2004
    Posts
    3

    Exclamation Unanswered: Query Criteria for Several Date Fields

    I have three date fields with short date format.

    What would be the sql statement if I wanted the result of any of the date fields containing a certain month be returned.

    Ex. Table

    ID Date1 Date2 Date3
    1 01/15/04 02/01/04 01/06/04
    2 02/18/04 01/26/04 02/03/04
    3 01/15/04 01/26/04 01/01/04

    My prompt would say [Enter Month], so I enter 02.

    I would like it to return Rows 1 and 2, since a least one of those three date fields does have a date that begins with 02.

    Thanks in advance for the help!

  2. #2
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    select * from yourtable
    where [Enter Month]
    in (month(Date1),month(Date2),month(Date3))
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  3. #3
    Join Date
    Feb 2004
    Posts
    3
    Thanks for the syntax. Worked perfectly

Posting Permissions

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