Problem using an interlocked WHERE-Clause

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • kuhni

    Problem using an interlocked WHERE-Clause

    Hi everybody,

    I have a problem with my SQL-Statement:

    SELECT *
    FROM [Excel Export Query]
    WHERE (((Year > 2003) And (Month <= 6)) Or (Year = 2003))

    The WHERE-clause doesn't work properly. As result I receive all
    entries from 2003 and 2004 where the month is <= 6.
    But I need to get all entries from 2003 (month 1-12) and the entries
    from 2004 (month 1-6).

    Does anybody know, why this interlocked statement doesn't work?

    THANK YOU SO MUCH!

    Best wishes,
    Stephan
  • Stewart Allen

    #2
    Re: Problem using an interlocked WHERE-Clause

    Hi Stephan
    Try
    WHERE (((Year([YourDateField]) > 2003) And (Month([YourDateField]) <= 6)) Or
    (Year([YourDateField) = 2003))

    Stewart



    "kuhni" <stephankuhnert @gmx.de> wrote in message
    news:88afb50f.0 408100231.7f67f c14@posting.goo gle.com...[color=blue]
    > Hi everybody,
    >
    > I have a problem with my SQL-Statement:
    >
    > SELECT *
    > FROM [Excel Export Query]
    > WHERE (((Year > 2003) And (Month <= 6)) Or (Year = 2003))
    >
    > The WHERE-clause doesn't work properly. As result I receive all
    > entries from 2003 and 2004 where the month is <= 6.
    > But I need to get all entries from 2003 (month 1-12) and the entries
    > from 2004 (month 1-6).
    >
    > Does anybody know, why this interlocked statement doesn't work?
    >
    > THANK YOU SO MUCH!
    >
    > Best wishes,
    > Stephan[/color]


    Comment

    • John Winterbottom

      #3
      Re: Problem using an interlocked WHERE-Clause


      "kuhni" <stephankuhnert @gmx.de> wrote in message
      news:88afb50f.0 408100231.7f67f c14@posting.goo gle.com...[color=blue]
      > Hi everybody,
      >
      > I have a problem with my SQL-Statement:
      >
      > SELECT *
      > FROM [Excel Export Query]
      > WHERE (((Year > 2003) And (Month <= 6)) Or (Year = 2003))
      >
      > The WHERE-clause doesn't work properly. As result I receive all
      > entries from 2003 and 2004 where the month is <= 6.
      > But I need to get all entries from 2003 (month 1-12) and the entries
      > from 2004 (month 1-6).
      >
      > Does anybody know, why this interlocked statement doesn't work?[/color]

      SELECT *
      FROM [Excel Export Query]
      WHERE
      ([Year] = 2003)
      OR
      ([Year] = 2004 AND [Month] <= 6)


      Comment

      Working...