2017-02-03 7 views
1

私は訪問看護師として働いており、私の訪問のために予定されているAccess 2016データベースを持っています。 1つのレポートでは、週番号を使用して、「今週の予定」をグループ化して表示します。それが立っているので、一部の患者は延期されており、次回の予定は2016年の日付で、週番号51または52または53の2016年の誕生日です。前年度の週番号

この2016年の日付をレポートの上部に設定する方法はありますか?それとも、「古い」日付... 2016 ..... 2017のソートを維持していますか?つまり、最初に延期された2016の日付を表示し、次に2017を表示します。

レポートのソースはテーブルのクエリです。このクエリーでは、特定のエントリのNV_wknum:DatePart( "ww"、([Last S-Visit] +60)) 週番号(NVは次回の訪問、最後の訪問から60日後)です。この関数は、ISO 8601規格に準拠した任意の日付の年と週番号の両方が返されます

答えて

0

weeknumbersが51であるため、2016年の日付がなど、レポートの最後に表示さ...:

Public Function ISO_WeekYearNumber(_ 
    ByVal datDate As Date, _ 
    Optional ByRef intYear As Integer, _ 
    Optional ByRef bytWeek As Byte) _ 
    As String 

' Calculates and returns year and week number for date datDate according to the ISO 8601:1988 standard. 
' Optionally returns numeric year and week. 
' 1998-2007, Gustav Brock, Cactus Data ApS, CPH. 
' May be freely used and distributed. 

    Const cbytFirstWeekOfAnyYear As Byte = 1 
    Const cbytLastWeekOfLeapYear As Byte = 53 
    Const cbytMonthJanuary  As Byte = 1 
    Const cbytMonthDecember  As Byte = 12 
    Const cstrSeparatorYearWeek As String = "W" 

    Dim bytMonth     As Byte 
    Dim bytISOThursday   As Byte 
    Dim datLastDayOfYear   As Date 

    intYear = Year(datDate) 
    bytMonth = Month(datDate) 
    bytWeek = DatePart("ww", datDate, vbMonday, vbFirstFourDays) 

    If bytWeek = cbytLastWeekOfLeapYear Then 
    bytISOThursday = Weekday(vbThursday, vbMonday) 
    datLastDayOfYear = DateSerial(intYear, cbytMonthDecember, 31) 
    If Weekday(datLastDayOfYear, vbMonday) >= bytISOThursday Then 
     ' OK, week count of 53 is caused by leap year. 
    Else 
     ' Correct for Access97/2000+ bug. 
     bytWeek = cbytFirstWeekOfAnyYear 
    End If 
    End If 

    ' Adjust year where week number belongs to next or previous year. 
    If bytMonth = cbytMonthJanuary Then 
    If bytWeek >= cbytLastWeekOfLeapYear - 1 Then 
     ' This is an early date of January belonging to the last week of the previous year. 
     intYear = intYear - 1 
    End If 
    ElseIf bytMonth = cbytMonthDecember Then 
    If bytWeek = cbytFirstWeekOfAnyYear Then 
     ' This is a late date of December belonging to the first week of the next year. 
     intYear = intYear + 1 
    End If 
    End If 

    ISO_WeekYearNumber = CStr(intYear) & cstrSeparatorYearWeek & Format(bytWeek, "00") 

End Function 

別の週システムを使用することができます。それからちょうど - レポートに - 60日は2ヶ月を意味している場合

Year(DateAdd("d",60,[Last S-Visit])) 

上の最初の並べ替え、その後

DatePart("ww",DateAdd("d",60,[Last S-Visit])) 

に、その後数ヶ月を追加します。

Year(DateAdd("m",2,[Last S-Visit])) 

その後、上:

DatePart("ww",DateAdd("m",2,[Last S-Visit])) 

すべてのソートを削除することを忘れないでくださいレポートを駆動するクエリ。ソートはレポート自体で指定する必要があります。