- Goal
日付からISO8601方式での年+週番号(YY-WWのフォーマット)で出力する。
ISO8601では、月曜日が週の始まりで、最初の木曜日を含む週が、その年の第1週として計算する。
- Sourceサンプル
手順: 1. ターゲットの日付を含む週の月曜日を求めて、年を算出する
2. ISO方式を考慮した週番号を算出する。
想定結果(YY-WW): 2017/01/01(SUN) = 16-52
2018/01/01(MON) = 18-01
2019/01/01(TUE) = 19-01
2020/01/01(WED) = 20-01
2021/01/01(FRI) = 20-53
2022/01/01(SAT) = 21-52
2023/01/01(SUN) = 22-52This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersPrivate Sub Command1_Click() Dim A As String Dim TEST_D As Date TEST_D = #1/1/2018# A = Format(TEST_D - (Weekday(TEST_D, vbMonday) - 1), "yy") & "-" & Format((DatePart("ww", TEST_D, vbMonday, vbFirstFourDays)), "00") Print A End Sub
- 参考 Thanks!!
DatePart function - Microsoft Developer Network
年月日から週番号 : 計算結果の確認用
Oracle Application Express Notes | Apps development Notes | Google Cloud Platform | Python | apps test | Cool Beans | English | Books
2017/01/17
日付から年と週番号を求める - ISO方式 / VB6の場合
登録:
コメントの投稿 (Atom)
0 件のコメント:
コメントを投稿