このコンテキストでは日付を扱っていることに注意してください。したがって、そうすると、Date() - 1
今日より 1 日早くなります。
Date()
〜今日の日付
DatePart(
"w" - Weekday
Date() - Today's date
2 - vBMonday (Access assumes Sunday is the first day of the week, which is why this is necessary.)
1 - vbFirstJan1 - This gets into using the first week of the year. We could have omitted this, as 1 is the default.
)
-1 - Subtract 1 from the DatePart value.
値
Date() = 4/27/2015 (at time of this writing)
DatePart("w",Date(),2,1) = 1
DatePart("w",Date(),2,1)-1 = 0
だから私たちはDate()-0
... わかりました、それの何がそんなに素晴らしいのですか? さて、今日の日付が月曜日以外の日である、より有用なシナリオを見てみましょう。
今日が2015/4/28(火)だとしよう
Date() = 4/28/2015
DatePart("w",Date(),2,1) = 2
DatePart("w",Date(),2,1)-1 = 1
だから、外側から、内側に。現在の平日の値を教えてください。weekday
(1 = 月曜日、2 = 火曜日など)、それから 1 を引く ->値 1 (月曜日)に戻すには、現在の日付から何日引く必要があるかを示します。