Results 1 to 5 of 5
  1. #1
    CBaigent is offline Novice
    Windows 10 Access 2016
    Join Date
    May 2016
    Posts
    2

    DSum and dates...I need help!

    Hello, All; thank you for reading.



    I am trying to use the DSum function in a query, with the goal of adding all daily temperatures between specified dates. I have spent a solid two days reading and modifying equations, to no avail. My last attempt looked something like this (I am finding conflicting information regarding the use of brackets and quotes); Temp_F is a field in a table and the expression I am attempting to sum, HOBO_Weather_Station_Raw is the domain (a table in my database), and the dates are my criteria. Obviously I am somewhat of a novice...any help you might provide would be so, so, hugely appreciated!

    ADD: DSum("[Temp_F]","HOBO_Weather_Station_Raw","[Data_Date]>=#1/1/2016#") - I have also attempted innumerable combinations with/without brackets, quotes, etc.

  2. #2
    orange's Avatar
    orange is offline Moderator
    Windows 8 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,726
    I suggest you tell readers what that SUM represents to you in plain English. We can not suggest HOW until we understand WHAT you are trying to do.

  3. #3
    CBaigent is offline Novice
    Windows 10 Access 2016
    Join Date
    May 2016
    Posts
    2
    "...with the goal of adding all daily temperatures between specified dates"

    I have specific blocks of time (defined by calendar dates), within those dates I have daily temperature readings (degrees in Fahrenheit), I would like to find the sum of those temperature readings.

    I hope that clarifies what I am after.

  4. #4
    ssanfu is offline Master of Nothing
    Windows XP Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    I would use a totals query, not DSUM() in a query.

    Is the date field just the date or is it date and time? If the date field also has the time the following probably won't work.
    Might need to create a column in the query that is just the date.

    Maybe try:
    Code:
    SELECT Sum(HOBO_Weather_Station_Raw.Temp_F) AS SumOfTemp, HOBO_Weather_Station_Raw.Data_Date
    FROM HOBO_Weather_Station_Raw 
    GROUP BY HOBO_Weather_Station_Raw.Data_Date
    HAVING HOBO_Weather_Station_Raw.Data_Date >=#1/1/2016#;
    Here is the query aliased (your table name is LONG!
    Code:
    SELECT Sum(H.Temp_F) AS SumOfTemp, H.Data_Date
    FROM HOBO_Weather_Station_Raw H
    GROUP BY H.Data_Date
    HAVING H.Data_Date >=#1/1/2016#;


    ------------------------------------------

    If the date and time is in the date field, try:
    Code:
    SELECT Sum(HOBO_Weather_Station_Raw.Temp_F) AS SumOfTemp, CDate(Int([Data_Date])) AS OnlyDate
    FROM HOBO_Weather_Station_Raw 
    GROUP BY HOBO_Weather_Station_Raw.OnlyDate
    HAVING HOBO_Weather_Station_Raw.OnlyDate >=#1/1/2016#
    ORDER BY ContractDates.Data_Date;
    Here is the query aliased
    Code:
    SELECT Sum(H.Temp_F) AS SumOfTemp, H.CDate(Int([Data_Date])) AS OnlyDate
    FROM HOBO_Weather_Station_Raw H
    GROUP BY H.OnlyDate
    HAVING H.OnlyDate >=#1/1/2016#;
    ORDER BY ContractDates.Data_Date;

    Warning:
    These queries are untested!!!

  5. #5
    orange's Avatar
    orange is offline Moderator
    Windows 8 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,726
    Hmmm...
    I would like to find the sum of those temperature readings.
    I'm curious--what will you do with the sum of several temperatures?

    You might consider Avg. Just a guess. Good luck.

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

Similar Threads

  1. Dsum function using mulitple criteria (specific: dates)
    By QA_Compliance_Advisor in forum Programming
    Replies: 10
    Last Post: 07-08-2015, 10:29 AM
  2. Replies: 1
    Last Post: 06-26-2015, 05:05 AM
  3. Replies: 2
    Last Post: 06-17-2013, 11:24 AM
  4. Dsum data between to dates for this year and last year
    By sdel_nevo in forum Programming
    Replies: 1
    Last Post: 06-13-2013, 06:48 AM
  5. filter dsum between dates on a form
    By sdel_nevo in forum Forms
    Replies: 5
    Last Post: 06-03-2013, 03:07 PM

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