0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

【Power Automate】協定世界時(UTC)からの変換とエラーハンドリング

Last updated at Posted at 2025-07-05

Power Automateで取得する日時は協定世界時(UTC)なので、日本標準時に変換が必要であることはよく知られています。

そのため、convertFromUtc関数を使って変換することが多いです。

Power Automate
convertFromUtc(utcNow(), 'Tokyo Standard Time')

utcNow()は現在の日時です。

結果の形式を指定するときには、下記のように指定します。

Power Automate
convertFromUtc(utcNow(), 'Tokyo Standard Time','yyyy/MM/dd HH:mm:ss')

utcNow()の部分は実際にはその前のアクション等で取得した動的なコンテンツを利用すると思います。
ここで注意点なのですが、utcNow()の部分は、「yyyy-MM-ddTHH:flag_mm:ss.fffffffK」(一部が勝手に絵文字になっちゃう:sweat_smile:)以外の形式ではエラーとなりますので、例えば動的なコンテンツの中で結果が日付以外に空(Null)で返って来る場合があると、当然エラーとなります。

例えば、Plannerの「タスクを一覧表示します」というアクションで、特定のプランのPlannerタスクを取得し、その中で完了から1年経過しているタスクを削除する、というフローを作成したいとします。
プランの中には、当然に未完了のタスクもあるので、そのままconvertFromUtc関数で変換しようとエラーになります。

そのため、convertFromUtc関数で処理する前に、条件分岐で事前にタスクの達成率が「100(=完了済み)」であるもののみに対して日付の変換の処理する等の工夫が必要があります。

【参考記事】
Qiita記事:【Power Automate】日時を扱う際のタイムゾーン変換
Qiita記事:PowerAutomateに日時型なんてものはない
外部記事:Power Automate 「convertFromUtc」関数
外部記事:Power Automate 「タスクを一覧表示します(Planner)」アクション

0
0
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
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?