Results 1 to 4 of 4
  1. #1
    kanchanj88 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Nov 2015
    Posts
    4

    Extract production data for only 24 hours from a given date and time

    Hi,

    I would appreciate any help with this problem.

    At our place, we make different products for a few days of a week (production time anywhere between 20 to 72 hours of production time). The data is in the attached zip folder. I need to know how much of a particular product is made in the first 24 hours of a given date and time.

    For example: (small extract from data)
    LastOfDateTime Product Amount
    2/3/2015 17:58 A1 42978.13
    2/3/2015 18:06 A1 3069.87
    2/3/2015 19:07 A1 14843.00
    2/3/2015 23:31 A1 60749.00
    2/4/2015 00:49 A2 18207.76
    2/4/2015 02:50 A2 31799.18
    2/4/2015 04:05 A1 17280.00
    2/4/2015 05:54 A3 24192.00
    2/4/2015 17:58 A3 12087.04
    2/4/2015 18:57 A3 13813.76
    2/4/2015 20:50 A5 25888.00
    2/4/2015 22:10 A2 16956.51
    2/5/2015 01:02 A1 37760.00
    2/5/2015 05:36 A2 72425.86
    2/5/2015 05:58 A2 6396.72
    2/5/2015 10:48 A2 73562.31
    2/5/2015 14:00 A6 44493.32
    2/9/2015 05:13 A1 45824.00
    2/9/2015 05:58 A1 8853.90
    2/9/2015 07:34 A1 20659.10
    2/9/2015 12:33 A6 64309.97
    2/9/2015 13:57 A6 18646.66
    2/9/2015 17:59 A6 59414.32
    2/9/2015 18:43 A6 7245.65
    2/9/2015 20:16 A6 23673.32
    2/10/2015 01:42 A2 74037.36
    2/10/2015 05:58 A2 70492.17

    From the above data, if I enter 02/10/15 01:00 then I would need sum of all Amount data for the 24 hours before it, by product, i.e., till 02/09/15 01:00; A1 = 75337.00; A6 = 173289.92

    Please let me know if you have any questions.

    Thank you for the help.
    Attached Files Attached Files

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,825
    Maybe something like:

    SELECT Product, Sum(Amount) AS SumAmt FROM table WHERE datefield BETWEEN [enter date and time] -1 AND [enter date and time] GROUP BY Product;
    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
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,521
    Sum your fields, but only use the date field as a where, and enter your range. Don't show it in the query.
    Better is to have a form with a start date/time. A hidden text box would have txtStart + 24 hrs,
    txtEnd = dateAdd("h",24,txtStart)
    The query will use this in the SQL,
    select sum(hrs) from table where [date] between forms!frmRpt!txtStart and forms!frmRpt!txtEnd

  4. #4
    CJ_London is offline VIP
    Windows 8 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,398
    assuming your fields are date types - dates are actual a number, the value before the decimal point represents days (today is 42355, tomorrow is 42356) and the bit after the decimal point represents the time expressed as a fraction of the number of seconds in 24 hours (60 secs * 60mins * 24 hrs=86400 seconds) - so 9am = 0.375, 9:05:36=32736/86400=0.378888

    investigate using the datediff function to subtract 24 hours from your entered date - or if always a full day, simply subtract 1 from your entered date e.g.

    where lastofdatetime between [Enter a date/time]-1 and [Enter a date/time]

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

Similar Threads

  1. Replies: 1
    Last Post: 04-01-2015, 01:29 AM
  2. Replies: 3
    Last Post: 08-20-2014, 01:47 PM
  3. Replies: 7
    Last Post: 06-25-2014, 08:01 AM
  4. Replies: 14
    Last Post: 09-11-2013, 01:10 PM
  5. Replies: 4
    Last Post: 08-06-2012, 10: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