自分用メモ
フィールドフィルター使えない状況の対処
ポスグレ使用環境
1.テキストで指定する場合
フィルターをテキストに設定して YYYY/MM で年月を入力して使うようにする
【指定月の表示】
to_char(date, 'YYYY/MM') = {{text}}
2.日付で指定する場合
キャストしないとエラる
【指定月の表示】
date_trunc('month', date) = date_trunc('month', cast({{day}} as timestamp))
【指定月から一ヶ月前までの表示】
date_trunc('month', date) between date_trunc('month', date_trunc('month', cast({{day}} as timestamp)) - interval '1 day') and date_trunc('month', cast({{day}} as timestamp))
ex.当月をデフォルト値にしたい場合
指定した時だけ当月指定の記述をコメントアウトするようにすればおk
date_trunc('month', date) = [[date_trunc('month', cast({{day}} as timestamp)) --]]date_trunc('month', current_timestamp)
フィールドフィルター以外でももうちょっとフィルターの幅増やして欲しい