Results 1 to 5 of 5
  1. #1
    habiler is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Aug 2017
    Posts
    13

    count the weekend in a total of days

    Hello has all,

    In the continuity of adjoining days I try to fill the space leave by the weekends.

    In fact I have a field LaDate with the data
    1- In May 01st


    1 - May 02nd
    1 - May 03rd
    1 - May 04th Saturday,
    1 - May 05th Sunday,
    1 - May 06th
    2 - May 01st
    2 - May 02nd
    2 - May 03rd

    As result I would like to have:
    1 - May 01st - May 06th 6 days
    2 - May 01st - May 03rd 3 days

    Thanks to all

    Habiler

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,525
    make a query to get the Max and Min of the record
    Q1: select id, Max(dateFld),Min(DateFld)

    then Q2 , use Q1 to get the #days
    Q2: select MaxOfDate - MinOfDate as TotalDays from Q1

  3. #3
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    You want to concatenate the first and last records of each group as well as count?

    Does that first record really have the word 'In'? Why? Are the words 'Saturday' and 'Sunday' really in the data?

    Try an aggregate (GROUP BY) query.

    SELECT field1, Min(field2) & " - " & Max(field2) AS Period, Count(*) AS CntDays FROM tablename GROUP BY field1;

    However, this won't work if the date range for each group crosses months because you are using month names.
    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.

  4. #4
    habiler is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Aug 2017
    Posts
    13
    Hello,

    My problem was completely badly written.

    In fact I have a field LaDate with the data
    1- May 01st
    1 - May 02nd
    1 - May 03rd
    (1 - May 04th Saturday, ) - Don't appear in the DB
    (1 - May 05th Sunday, ) - Don't appear in the DB
    1 - May 06th
    1 - May 07th
    1 - May 18th
    2 - May 03rd
    (Weekend 4 & 5/5)
    2 - May 06th
    2 - May 07th
    2 - Jun 01st
    As result I would like to have:
    1 - May 01st - May 07th 5 day
    1 - May 18th - May 18th 1 days
    2 - May 03rd - May 07th 3 days
    2 - Jun 01st - Jun 01st 1 day

    I've written this code by i can't include the WE.

    Code:
    Public Function nbJ(nP As Long, d1 As Date)
       Dim n As Long, sSQL As String
       n = 0
       While True
          n = n - 1
          sSQL = "NR_WKN = " & nP & " And PERIODE = #" & Format(DateAdd("d", n, d1), "yyyy-mm-dd") & "#"
          'Debug.Print sSQL,
          'Debug.Print Nz(DCount("*", "Maladies", sSQL))
          If Nz(DCount("*", "Maladies", sSQL)) = 0 Then
             nbJ = n
          Exit Function
          End If
       Wend
    End Function

  5. #5
    aytee111 is offline Competent At Times
    Windows 10 Access 2013 64bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    See if this is doing what you want.
    Attached Files Attached Files

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

Similar Threads

  1. Replies: 9
    Last Post: 03-07-2016, 04:17 PM
  2. Replies: 2
    Last Post: 08-17-2015, 09:53 AM
  3. Replies: 2
    Last Post: 04-15-2014, 01:59 PM
  4. Count Days...
    By sdc1234 in forum Queries
    Replies: 1
    Last Post: 02-06-2014, 09:31 AM
  5. Total no of days in a month
    By wasim_sono in forum Forms
    Replies: 4
    Last Post: 10-15-2006, 01:05 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