Notionの数式機能はとても便利ですが、まだchat-GPTの精度も高くなく、求めている数式がGPT頼りでなかなか作れません。

今回、タスク管理をNotionにする上で、「3営業日前」と「前週のhoge曜日」を表示させる数式を作成したので共有したいと思います。

 

ある日付プロパティの3営業日前の日付を表示する

lets(closedDays,["土","日"],start,dateSubtract(prop("日付").dateEnd(),5,"days"),end,prop("日付").dateEnd(),japaneseHolidays,["01-01","01-09","02-11","02-23","03-21","04-29","05-03","05-04","05-05","07-17","08-11","09-18","09-23","10-09","11-03","11-23"],days,dateBetween(end,start,"days"),dates,"x".repeat(days+1).split("").map((_, index) => !index ? start : start.dateAdd(index, "days")),substitutes,dates.filter(current => current.formatDate("EEE") == "日" && japaneseHolidays.includes(current.formatDate("MM-DD"))),substitutesLen,substitutes.length(),candidates,"x".repeat(5).split("").map((_, index) => lets(add,index+1,substitutes.map(current => current.dateAdd(add,"days")).filter(current => !closedDays.includes(current.formatDate("EEE")) && !japaneseHolidays.includes(current.formatDate("MM-DD"))))),substitutes,"x".repeat(substitutesLen).split("").map((_, index) => lets(subIdx,index,candidates.map(current => current.at(subIdx)).filter(current => !empty(current)).first())),businessDays,dates.filter(current => !closedDays.includes(current.formatDate("EEE")) && !japaneseHolidays.includes(current.formatDate("MM-DD")) && !substitutes.includes(current)).map(current => current.formatDate("MM月DD日(EEE)")),businessDays.at(-3))
 

 

営業日換算は以下を参考にしました。

 

考え方としては、lets関数を使って、土日・休日・振替休日を抜いた日付の配列の最後から3つ目を選択するというやつですね。

 

ある日付プロパティの前週のhoge曜日

今回は前週の金曜日を表示しました。
lets( dayofweek, day(prop("日付")), dateSubtract( prop("IL日付"), ifs( dayofweek == 0, 2, dayofweek == 1, 3, dayofweek == 2, 4, dayofweek == 3, 5, dayofweek == 4, 6, dayofweek == 5, 7, dayofweek == 6, 8 ), "days" ) )
 

考え方としては、lets関数を使って、指定の曜日だったら、何日前にするというやつですね。

 

良いNotonLIFEを!