Results 1 to 13 of 13
  1. #1
    nahum abramovich is offline Advanced Beginner
    Windows 7 64bit Access 2016
    Join Date
    Jun 2018
    Posts
    62

    cant write correctly dsum func


    hi. I need help in the Access form I created. If you can help, I would like to know how to sum values between time and time. For example, I tried this:
    dsum("[parts in holder]",[ database nahum ]", " [date=date() ]", between (12:00:00) and (18:00:00)) . not working

    I thought maybe because my [date] and [time] are in *separate columns* maybe i should do this :
    dsum("[parts in holder]",[ database nahum ]",
    "[date=date() ]","(12:00:00)<[time]<(18:00:00)")
    . not working

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,550
    you cannot put values/function inside quotes, they should be without quotes to resolve.
    your second param is missing a quote,
    and date/time uses # as a delimiter:

    dsum("[parts in holder]","[ database nahum ]", "[DateFld]=#" date() & "#" )

    dsum("[parts in holder]","[ database nahum ]", "[DateFld] between #" & txtTime1 & "# and #" & txtTime2 & #")

    NOTE: its best to combine date and time into a single field : 12/1/2018 12:45 pm
    (and not have 1 field for date and 1 field for time)

    this way your date math can perform across midnight

  3. #3
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,929
    agree with ranman and also point out that date and time are reserved words - date is a function which returns today and time returns the current time (now returns the current date and time) - so it is advisable not to use as as field names as it will confuse sql. Recommend changing them to something more meaningful such as 'inputdate'.

    Also spaces in field and table names are not advised since again, they cause problems.

    Finally, not mentioned but spaces before or after names won't work so this

    "[ database nahum ]"

    should be

    "[database nahum]"

  4. #4
    nahum abramovich is offline Advanced Beginner
    Windows 7 64bit Access 2016
    Join Date
    Jun 2018
    Posts
    62
    Thanks so much for your response.for now I can not connect the column of the [date] with the [time] column for some reason . I'd be happy to explain to you exactly what I want to do and maybe you could help me write it down properly.

    I have a column of [parts in holder].
    I have a column of [date].
    i have a column of [time].
    All this is in the [database nahum] table.

    I want to get feedback of the
    [parts in holder] Productivity in 3 shifts so i can see it in my form (inside 3 box) every morning.
    1 shift is between (08:00:00) and (17:00:00)
    shift 2 is between (17:00:00) and (00:00:00)
    shift 3 is between (00:00:00) and (08:00:00)

    now if i understood you correctly this are the 3 rows that i need to write.

    for shift 1 (see the date -1 for the day before)

    dsum("[part in holder]","[database nahum]","[date]=date()-1 between #"&(08:00:00)&"# and #"&(17:00:00)&"#")

    for shift 2 - (see the date -1for the day before)

    dsum("[part in holder]","[database nahum]","[date]=date()-1 between #"&(17:00:00)&"# and #"&(00:00:00)&"#")

    for shift 3

    dsum("[part in holder]","[database nahum]","[date]=date() between #"&(00:00:00)&"# and #"&(08:00:00)&"#").

    need your help mf

  5. #5
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,929
    not quite right

    dsum("[part in holder]","[database nahum]","[date]=date()-1 and [Time] between #08:00:00# and #17:00:00#")

    you can see here

    [date]=date()-1

    how using a date as a field name is confusing

  6. #6
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,550
    date() will not resolve inside quotes.

  7. #7
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Quote Originally Posted by ranman256 View Post
    date() will not resolve inside quotes.
    Doesn't need to. The SQL engine understands the Date() function. The SQL string will construct referencing the Date() function and when the SQL executes it will evaluate Date() function and return the current date. Domain aggregate function will also evaluate Date() function within quote marks.

    Advise not to use spaces nor punctuation/special characters (underscore only exception) in naming convention. Better would be DatabaseNahum or Database_Nahum.
    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.

  8. #8
    nahum abramovich is offline Advanced Beginner
    Windows 7 64bit Access 2016
    Join Date
    Jun 2018
    Posts
    62
    thank you all for the help its not obvious that you are helping.
    ajax- i tried your dsum but its no working. the box returns ×××error×××

  9. #9
    nahum abramovich is offline Advanced Beginner
    Windows 7 64bit Access 2016
    Join Date
    Jun 2018
    Posts
    62
    not working mf

  10. #10
    isladogs's Avatar
    isladogs is offline Access MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    6,204
    As you are still having trouble, consider creating a tblShifts with 3 fields: ShiftNumber (PK - integer), StartTime & EndTime. It will have 3 records.
    Now reference the ShiftNumber instead of the time values in your DSum formulas.
    This may make it easier to resolve issues

    Also as already stated by both ajax & ranman, do rename the Date field to prevent confusion & avoid risk of unpredictable results and combine with your equally badly named Time field
    However, please don't call the combined field DateTime!
    Colin Riddington, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I know I don't know, I keep quiet!

  11. #11
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    I tested the syntax suggested by Ajax and it works. Provide a sample of your data. If you want to provide db for analysis, follow instructions at bottom of my post.
    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.

  12. #12
    nahum abramovich is offline Advanced Beginner
    Windows 7 64bit Access 2016
    Join Date
    Jun 2018
    Posts
    62

    Combine data with time in one column

    NOTE: its best to combine date and time into a single field : 12/1/2018 12:45 pm


    Can you please teach me how to do it? I've set the column to GENERAL DATE (12/1/2018 12:45:05)
    but there is no view of time in the column w... just dates.

  13. #13
    isladogs's Avatar
    isladogs is offline Access MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    6,204
    Add a new record and include a time e.g. 09:30:00 as well as a date. It will then be displayed
    You may need to widen the field in table / form to see it.

    Existing records will have a time equal to 00:00:00 (which isn't displayed) until you add the time
    Those records can be updated by concatenating the date and time fields using an update query.
    After that delete your time field
    Last edited by isladogs; 06-04-2018 at 04:20 AM. Reason: Extra info
    Colin Riddington, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I know I don't know, I keep quiet!

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

Similar Threads

  1. Name not showing correctly
    By jopi in forum Reports
    Replies: 1
    Last Post: 05-12-2016, 08:38 AM
  2. WHERE not working correctly?
    By aellistechsupport in forum SQL Server
    Replies: 5
    Last Post: 01-02-2016, 04:24 AM
  3. Query not sorting correctly?
    By Areteauu in forum Queries
    Replies: 2
    Last Post: 01-27-2014, 02:37 PM
  4. Replies: 15
    Last Post: 12-10-2012, 06:37 PM
  5. Replies: 16
    Last Post: 08-19-2010, 01:40 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