LoginSignup
0
1

More than 1 year has passed since last update.

【Google Apps Script/Spreadsheet/Gmail】includes()で日付を比較する時に沼に陥ったので解決した方法をまとめておく。

Last updated at Posted at 2021-11-12

Google Apps Scriptで条件を指定してメールを取得しSpreadsheetに記述するという時に新しいメールかどうかを日付で判断しようと思ってSpreadsheetにある日付を取得してリストにし、includesで比較したら何故か別のSpreadsheetではうまくいったのに、うまくいかな行ことがありその際に解決した方法をまとめておきます。

簡潔解決法をにいうと、

Date.parse()

を使って、リスト・Gmailから取得する日付ともに

Thu Nov 11 2021 21:51:35 GMT+0900 (Japan Standard Time)

上記形式から以下のように変換して比較しました。

1636635095000

その結果、includesでリストを比較できるようになりました。

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1