Results 1 to 5 of 5
  1. #1
    broecher is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    Sep 2010
    Posts
    38

    dsum help - running sum N days before and after

    My expression outputs nothing (blank), and it is very slow... Can someone tell me what I did wrong?

    I am looking for the sum of the values in the column DayFixCount, but only if the short date in the column all_dates is within 3 days. The name of the query i am in is qry_9fixTotals.



    Code:
    expr1: DSum("DayFixCount","qry_9fixTotals","[all_dates] >=" & [all_dates]-3 & "And [all_dates] <=" & [all_dates]+3)
    I can't seem to get any simpler DSum expressions to work either - if they contain the & symbol. Maybe this is not the correct method for my version of Access?

    I'm using access 2002.

    Thanks

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,928
    Need # delimiter for date criteria, text uses apostrophe, numbers nothing. Also needed a space in front of And so it doesn't run into date value. Use BETWEEN AND with inclusive range.

    DSum("DayFixCount","qry_9fixTotals","[all_dates] BETWEEN #" & [all_dates]-3 & "# AND #" & [all_dates]+3 & "#")

    Does all_dates include time?
    Last edited by June7; 09-26-2012 at 09:35 PM.
    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
    broecher is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    Sep 2010
    Posts
    38
    Thanks June7! So I can use BETWEEN in the "design view" or does this have to be entered in SQL view?

    Need # delimiter for date criteria, text uses apostrophe, numbers nothing.
    I don't understand what you mean about apostrophes and numbers.

    all_dates is just a short date like 09/20/2010.

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,928
    Either.

    A date value is actually stored as a number but because of the datatype, Access displays the value in a date/time structure and will deal with the value like a date/time. Regardless of the display format setting, the value still has date and time components. If you don't save time (like 3:45:27 PM), Access just doesn't show time parts, which would be 00:00:00. It is also possible to save only the time part and the date won't show.

    The WHERE CONDITION of domain aggregate function is like the WHERE clause of an sql statement. Criteria must be delimited. If the field is a date/time type, use # characters. They force Access to treat the value as date/time entity, and not just a string of characters. For text fields, apostrophe (or two quote marks) must be used and for number fields no delimiters.
    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.

  5. #5
    broecher is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    Sep 2010
    Posts
    38
    it worked thanks so much!

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

Similar Threads

  1. Dsum Help?
    By Ragin_roider in forum Queries
    Replies: 5
    Last Post: 03-19-2012, 03:10 PM
  2. Help with Sum and DSum
    By objNoob in forum Reports
    Replies: 5
    Last Post: 12-05-2011, 01:55 AM
  3. How do I use the DSum
    By Ironclaw in forum Access
    Replies: 1
    Last Post: 08-25-2010, 07:35 AM
  4. Select Dates between days and two days ago?
    By rstonehouse in forum Queries
    Replies: 4
    Last Post: 08-18-2010, 02:13 AM
  5. Help with dsum
    By bjsbrown in forum Reports
    Replies: 6
    Last Post: 02-06-2010, 09:33 AM

Tags for this Thread

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