Results 1 to 3 of 3
  1. #1
    Join Date
    Aug 2007
    Posts
    9

    Unanswered: Running a Query for the Month

    Hi,

    I am trying to run a query that will show me specific fields that have been manipulated for a specific month. Ideally, i would like to create a text box with a button next to it, when a month is entered into the text box the query recognises the month and shows the relevant data for that specific month.

    I hope thats clear and i would be really grateful if anyone can help me.

    Kind Regards,

    t1ish

  2. #2
    Join Date
    May 2005
    Location
    Nevada, USA
    Posts
    2,888
    Provided Answers: 6
    There are date functions here that will let you get the first and last days of the input date:

    http://www.pacificdb.com.au/MVP/Code/Dates.htm

    Using those dates in your query will let you get the full month's data.
    Paul

  3. #3
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    Just one thing for you to think about:

    The user picks "January" as the month that they wish to display.
    01/01/2006
    01/01/2007
    01/01/2008
    etc

    Will all be included in the result set if you're not careful!
    Make sure you prompt for the year as well!
    Code:
    SELECT Field1, Field2, ... , FieldN, DateField
    FROM   MyTable
    WHERE  Month(DateField) = 1
    AND    Year(DateField) = 2007
    George
    Home | Blog

Posting Permissions

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