Results 1 to 7 of 7
  1. #1
    jasonbarnes is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Dec 2010
    Location
    NC
    Posts
    56

    Query/Filter by Date

    I have a table in my database that has a date field (we'll call salesdate). I use this table in a query, which is in turn linked to an excel spreadsheet and turned in a pivot table.



    Here is my question. The salesdate field is formatted as XX/XX/XXXX. The pivot table shows the entire tables data. I would like to be able to filter in the pivot table by month instead of having to click 30 days each month. So the end user could go the filter or control, and filter by August 2010 for example.

    I read Excel 2010 has a new type of filter where you could filter by a date range but I am using 2007. I also played with changing the database itself or the query in Access. Could I have an Expr field that modifies the salesdate field? This would in turn create a better field to use a filter by having a list (August 2010, September 2010, or ...Sept-10, Aug-10 etc.

    Any advice on the most practical solution is appreciated.

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Could use an expression to construct a field that returns a string value of Month and Year.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    Stingaway is offline Efficiency Junkie
    Windows 7 64bit Access 2010 64bit
    Join Date
    Sep 2011
    Location
    The deep south. Keep going until you hit water basically.
    Posts
    224
    Excel 2007 has this ability as well. You just need to add a column to your pivot data that uses the year function on the date field in question. From there add it to your pivot table and you can filter that in the drop down by selecting the column in the data first...

  4. #4
    jasonbarnes is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Dec 2010
    Location
    NC
    Posts
    56
    I used

    Month: Month(SalesDate) to get the month and
    Year: Year(SalesDate) to get the year

    Is there a simple trick to convert the number to text? (In either the query or pivot).. I tried formatting the column as text or date but the close I can get is... "January-00"

  5. #5
    Stingaway is offline Efficiency Junkie
    Windows 7 64bit Access 2010 64bit
    Join Date
    Sep 2011
    Location
    The deep south. Keep going until you hit water basically.
    Posts
    224
    For the month column in an access query you can use the MonthName function.

    Example, Monthname(1) will yield "January".

  6. #6
    Stingaway is offline Efficiency Junkie
    Windows 7 64bit Access 2010 64bit
    Join Date
    Sep 2011
    Location
    The deep south. Keep going until you hit water basically.
    Posts
    224
    So in this case in Access you could actually say Monthname(Month(SalesDate))

  7. #7
    jasonbarnes is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Dec 2010
    Location
    NC
    Posts
    56
    Perfect! Thanks for the help.

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

Similar Threads

  1. Code to combine report filter and date range
    By rhubarb in forum Reports
    Replies: 17
    Last Post: 10-28-2011, 03:08 PM
  2. Filter to a date range ala Allen Brown
    By kekawaka in forum Forms
    Replies: 2
    Last Post: 10-10-2011, 12:19 PM
  3. Date Range filter in a Duplicate query
    By knickolyed in forum Forms
    Replies: 0
    Last Post: 06-27-2011, 04:56 AM
  4. Filter By Date In Different Fields
    By Douglasrac in forum Queries
    Replies: 13
    Last Post: 03-21-2011, 05:24 PM
  5. Filter by date
    By adsm in forum Forms
    Replies: 3
    Last Post: 08-20-2010, 06:50 AM

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