Results 1 to 2 of 2
  1. #1
    Playerpawn is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Posts
    11

    Best way to check date.

    EDIT:

    Can the following part of my select statement be improved:

    SUM(IIf(Month(sub.date_entered) = Month(now()) & Year(sub.date_entered) = Year(now()), sub.qty, 0)) as current_month,


    SUM(IIf(Month(sub.date_entered) = Month(DateAdd("m",-1,date())) & Year(sub.date_entered) = Year(DateAdd("m",-1,date())), sub.qty, 0)) as prior_1

    ... followed by lines summing sub.qty going back month by month into seperate columns.

    2nd question: How in Access can I dynamically alias the columns (as they will need to adjust depending on current month).

    Seems to not work. Always evaluates as 0. I assume I can't use & for two conditions. I'll Google that one.

  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
    Cannot dynamically alias column names.

    Ampersand is concatenation operator, AND is logical operator, along with OR.
    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.

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

Similar Threads

  1. Date and time check
    By polis in forum Programming
    Replies: 2
    Last Post: 09-30-2011, 09:26 AM
  2. Check dosent update current date
    By bsunuwar in forum Access
    Replies: 10
    Last Post: 03-23-2011, 09:46 PM
  3. Replies: 1
    Last Post: 07-07-2010, 04:22 PM
  4. To check or Un-Check all Boxes in a form
    By devcon in forum Forms
    Replies: 7
    Last Post: 05-01-2010, 12:03 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