Results 1 to 3 of 3
  1. #1
    drunkenneo is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Jun 2013
    Posts
    199

    Date logic


    I have a date stored, lets say 22/07/2013, and i have a table with entry date, and ordernumber.

    i want to write a count of all the ordernumbers they were in month of july i.e from taking month and year from current month, from coding.
    Thanks in advance..

  2. #2
    JoeM is offline VIP
    Windows XP Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    Do you mean something like this?
    Code:
    SELECT Count(MyTable.OrderNumber) AS CountOfOrderNumber
    FROM MyTable
    WHERE (((MyTable.EntryDate) Between #1/7/2013# And #31/7/2013#));

  3. #3
    JoeM is offline VIP
    Windows XP Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    Or, if you are getting your month and date from some variable or fields somewhere, this may work better:
    Code:
    SELECT Count(MyTable.OrderNumber) AS CountOfOrderNumber
    FROM MyTable
    WHERE (((Month([MyTable]![EntryDate]))=7) AND ((Year([MyTable]![EntryDate]))=2013));
    If doing it from VBA code where you are building the SQL code from some form fields, substitute those in for the hard-coded values of "7" and "2013".

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

Similar Threads

  1. Need to know the logic behind the formula
    By Johin.b in forum Access
    Replies: 2
    Last Post: 07-16-2013, 03:21 AM
  2. code logic help
    By jscriptor09 in forum Programming
    Replies: 1
    Last Post: 10-28-2012, 09:38 AM
  3. Please help with the logic
    By Del23 in forum Access
    Replies: 1
    Last Post: 08-23-2012, 12:13 PM
  4. need better VBA logic than I currently have
    By jscriptor09 in forum Programming
    Replies: 4
    Last Post: 11-27-2011, 09:16 AM
  5. Can't get the logic right.
    By Nouri31 in forum Queries
    Replies: 3
    Last Post: 03-31-2011, 08:25 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