いつの間にか便利な日付系の関数「EDate関数」と「EOMonth関数」が追加されていたので、簡単にご紹介。
EDate関数
EDate関数はnか月後の日付を求める関数で、DateAdd関数の単位を「月」にしたときと同じ動作(のよう)。
動作イメージはこんな感じ。


月末の日付に対してEDate関数を使用した場合は指定した月後の月末の日付を返してくれる。


EOMonth関数
EOMonth関数は指定した月後の月末の日付を返してくれる。
動作イメージはこんな感じ。


このEOMonthを使って、指定した年月の全日付をコレクションに入れる式は以下のようになるかな。
※もっと簡単な式あるかもだけど。
※もっと簡単な式あるかもだけど。
With({start:Date(求めたい年, 求めたい月, 1)}, With({end:EOMonth(start, 0)}, ClearCollect(dates, ForAll(Sequence(DateDiff(start, end, TimeUnit.Days) + 1), DateAdd(start, ThisRecord.Value - 1, TimeUnit.Days) ) ) ) )
動作イメージ。


月末の日付を簡単に使用できるようになったのでとても助かる。
コメント