Results 1 to 5 of 5
  1. #1
    Join Date
    Jun 2005
    Posts
    6

    Finding data between two date for any year


    I'm trying to do a query to pull out data between 02/28/**** and 11/15/**** . Each time I put this in the query I getting a mix match data error. Is there a way better way to code this?

  2. #2
    Join Date
    Dec 2005
    Location
    Wilmington, DE - USA
    Posts
    275
    Something like this would work:

    SELECT <some fields>
    FROM <some table>
    WHERE DateField BETWEEN DateSerial(Year(DateField), 2, 28) AND DateSerial(Year(DateField), 11, 15)

  3. #3
    Join Date
    Dec 2005
    Location
    Wilmington, DE - USA
    Posts
    275
    OK, the editor turned eight-parenthesis to a smiley!


    SELECT <some fields>
    FROM <some table>
    WHERE DateField BETWEEN DateSerial(Year(DateField), 2, 28 ) AND DateSerial(Year(DateField), 11, 15)

  4. #4
    Join Date
    Jun 2005
    Posts
    6

    Finding data between two date for any year

    This is good,but I didn't get the results I was expecting and that was my fault. I should had said that I only want the data between 11/15**** and 02?23****. Therefore I shouldn't see any data before 11/15 of any year and nothing after 02/28 for any year. When coding what you sent me I'm getting dates showing for the month of 03, 04, 05, etc...

    Here is the code I used;
    Between DateSerial(Year([reportingdate]),11,15) And DateSerial(Year([reportingdate]),2,28)

    Even if I switch the dates around I get the same results.

  5. #5
    Join Date
    Dec 2005
    Location
    Wilmington, DE - USA
    Posts
    275
    gemini,

    The problem is that you are not using a between.

    SELECT <some fields>
    FROM <some table>
    WHERE (DateField <= DateSerial(Year(DateField), 2, 28 )) OR (DateField >= DateSerial(Year(DateField), 11, 15))

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

Similar Threads

  1. Changing a date to the current year
    By fdnyfish in forum Access
    Replies: 1
    Last Post: 03-01-2008, 08:34 AM
  2. Finding data that doesn't match
    By dlhayes in forum Queries
    Replies: 1
    Last Post: 11-11-2006, 08:14 PM
  3. Retrieving Week of Year in a date range
    By Korvega in forum Queries
    Replies: 2
    Last Post: 05-27-2006, 06:29 AM
  4. How to report data in fical year order
    By gemini2 in forum Reports
    Replies: 1
    Last Post: 05-27-2006, 06:26 AM
  5. Replies: 1
    Last Post: 12-09-2005, 10:29 PM

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