アクション テキスト

【PowerAutomateDesktop】日付(日時)の表示形式(書式)を変換する

ファイルを保存するときに、ファイル名の末尾にタイムスタンプを付けたい場合があるかと思います。

また、〇月〇日以降のデータのみ抽出したい、といったときにも日時の操作が必要になってきます。

アクション「datetimeをテキストに変換」のカスタム形式を使用すれば、柔軟な表示形式を実現することが可能になるので、ぜひご参考になさって下さい。

カスタム形式の設定例と参考フローのご紹介

ここでは、変数CurrentDateTimeの値が「2020/05/19 23:59:59」の場合の表示例を紹介していきます。
参考フローも載せているので、コピーして、PowerAutomateDesktopのMainフローに張り付ければ、そのまま実行することができます。

形式:yy 表示例:20

yy

DateTime.GetCurrentDateTime.Local DateTimeFormat: DateTime.DateTimeFormat.DateAndTime CurrentDateTime=> CurrentDateTime
Text.ConvertDateTimeToText.FromCustomDateTime DateTime: CurrentDateTime CustomFormat: $'''yy''' Result=> FormattedDateTime

 

形式:yyyy 表示例:2020

yyyy

DateTime.GetCurrentDateTime.Local DateTimeFormat: DateTime.DateTimeFormat.DateAndTime CurrentDateTime=> CurrentDateTime
Text.ConvertDateTimeToText.FromCustomDateTime DateTime: CurrentDateTime CustomFormat: $'''yyyy''' Result=> FormattedDateTime

 

形式:MM 表示例:05

MM

DateTime.GetCurrentDateTime.Local DateTimeFormat: DateTime.DateTimeFormat.DateAndTime CurrentDateTime=> CurrentDateTime
Text.ConvertDateTimeToText.FromCustomDateTime DateTime: CurrentDateTime CustomFormat: $'''MM''' Result=> FormattedDateTime

 

形式:dd 表示例:19

dd

DateTime.GetCurrentDateTime.Local DateTimeFormat: DateTime.DateTimeFormat.DateAndTime CurrentDateTime=> CurrentDateTime
Text.ConvertDateTimeToText.FromCustomDateTime DateTime: CurrentDateTime CustomFormat: $'''dd''' Result=> FormattedDateTime

 

形式:ddd 表示例:火

ddd

DateTime.GetCurrentDateTime.Local DateTimeFormat: DateTime.DateTimeFormat.DateAndTime CurrentDateTime=> CurrentDateTime
Text.ConvertDateTimeToText.FromCustomDateTime DateTime: CurrentDateTime CustomFormat: $'''ddd''' Result=> FormattedDateTime

 

形式:HH 表示例:23

HH

DateTime.GetCurrentDateTime.Local DateTimeFormat: DateTime.DateTimeFormat.DateAndTime CurrentDateTime=> CurrentDateTime
Text.ConvertDateTimeToText.FromCustomDateTime DateTime: CurrentDateTime CustomFormat: $'''HH''' Result=> FormattedDateTime

 

形式:hh 表示例:11

hh_small

DateTime.GetCurrentDateTime.Local DateTimeFormat: DateTime.DateTimeFormat.DateAndTime CurrentDateTime=> CurrentDateTime
Text.ConvertDateTimeToText.FromCustomDateTime DateTime: CurrentDateTime CustomFormat: $'''hh''' Result=> FormattedDateTime

 

形式:mm 表示例:59

mm_small

DateTime.GetCurrentDateTime.Local DateTimeFormat: DateTime.DateTimeFormat.DateAndTime CurrentDateTime=> CurrentDateTime
Text.ConvertDateTimeToText.FromCustomDateTime DateTime: CurrentDateTime CustomFormat: $'''mm''' Result=> FormattedDateTime

 

形式:ss 表示例:59

ss

DateTime.GetCurrentDateTime.Local DateTimeFormat: DateTime.DateTimeFormat.DateAndTime CurrentDateTime=> CurrentDateTime
Text.ConvertDateTimeToText.FromCustomDateTime DateTime: CurrentDateTime CustomFormat: $'''ss''' Result=> FormattedDateTime

 

形式:tt 表示例:午後

tt

DateTime.GetCurrentDateTime.Local DateTimeFormat: DateTime.DateTimeFormat.DateAndTime CurrentDateTime=> CurrentDateTime
Text.ConvertDateTimeToText.FromCustomDateTime DateTime: CurrentDateTime CustomFormat: $'''tt''' Result=> FormattedDateTime

 

形式:y 表示例:2020年5月

y

DateTime.GetCurrentDateTime.Local DateTimeFormat: DateTime.DateTimeFormat.DateAndTime CurrentDateTime=> CurrentDateTime
Text.ConvertDateTimeToText.FromCustomDateTime DateTime: CurrentDateTime CustomFormat: $'''y''' Result=> FormattedDateTime

 

形式:m 表示例:5月19日

m

DateTime.GetCurrentDateTime.Local DateTimeFormat: DateTime.DateTimeFormat.DateAndTime CurrentDateTime=> CurrentDateTime
Text.ConvertDateTimeToText.FromCustomDateTime DateTime: CurrentDateTime CustomFormat: $'''m''' Result=> FormattedDateTime

 

形式:d 表示例:2020/05/19

d

DateTime.GetCurrentDateTime.Local DateTimeFormat: DateTime.DateTimeFormat.DateAndTime CurrentDateTime=> CurrentDateTime
Text.ConvertDateTimeToText.FromCustomDateTime DateTime: CurrentDateTime CustomFormat: $'''d''' Result=> FormattedDateTime

 

形式:t 表示例:23:59

t

DateTime.GetCurrentDateTime.Local DateTimeFormat: DateTime.DateTimeFormat.DateAndTime CurrentDateTime=> CurrentDateTime
Text.ConvertDateTimeToText.FromCustomDateTime DateTime: CurrentDateTime CustomFormat: $'''t''' Result=> FormattedDateTime

 

形式:f 表示例:2020年5月19日 23:59

f

DateTime.GetCurrentDateTime.Local DateTimeFormat: DateTime.DateTimeFormat.DateAndTime CurrentDateTime=> CurrentDateTime
Text.ConvertDateTimeToText.FromCustomDateTime DateTime: CurrentDateTime CustomFormat: $'''f''' Result=> FormattedDateTime

 

形式:g 表示例:2020/05/19 23:59

g

DateTime.GetCurrentDateTime.Local DateTimeFormat: DateTime.DateTimeFormat.DateAndTime CurrentDateTime=> CurrentDateTime
Text.ConvertDateTimeToText.FromCustomDateTime DateTime: CurrentDateTime CustomFormat: $'''g''' Result=> FormattedDateTime

 

形式:s 表示例:2020-05-19T23:59:59

s

DateTime.GetCurrentDateTime.Local DateTimeFormat: DateTime.DateTimeFormat.DateAndTime CurrentDateTime=> CurrentDateTime
Text.ConvertDateTimeToText.FromCustomDateTime DateTime: CurrentDateTime CustomFormat: $'''s''' Result=> FormattedDateTime

 

形式:r 表示例:Tue, 19 May 2020 23:59:59 GMT

r

DateTime.GetCurrentDateTime.Local DateTimeFormat: DateTime.DateTimeFormat.DateAndTime CurrentDateTime=> CurrentDateTime
Text.ConvertDateTimeToText.FromCustomDateTime DateTime: CurrentDateTime CustomFormat: $'''r''' Result=> FormattedDateTime

 

形式:o 表示例:2020-05-19T23:59:59.0000000

o

DateTime.GetCurrentDateTime.Local DateTimeFormat: DateTime.DateTimeFormat.DateAndTime CurrentDateTime=> CurrentDateTime
Text.ConvertDateTimeToText.FromCustomDateTime DateTime: CurrentDateTime CustomFormat: $'''o''' Result=> FormattedDateTime

 

形式:yyyyMMdd_HHmmss 表示例:20200519_235959

ファイルを保存するときのタイムスタンプに利用しやすい形式です。
yyyyMMdd_HHmmss

DateTime.GetCurrentDateTime.Local DateTimeFormat: DateTime.DateTimeFormat.DateAndTime CurrentDateTime=> CurrentDateTime
Text.ConvertDateTimeToText.FromCustomDateTime DateTime: CurrentDateTime CustomFormat: $'''yyyyMMdd_HHmmss''' Result=> FormattedDateTime

 

形式:yyyy/MM/dd(ddd) 表示例:2020/05/19(火)

曜日と組み合わせて日付を作成することもできます。
yyyy/MM/dd(ddd)

DateTime.GetCurrentDateTime.Local DateTimeFormat: DateTime.DateTimeFormat.DateAndTime CurrentDateTime=> CurrentDateTime
Text.ConvertDateTimeToText.FromCustomDateTime DateTime: CurrentDateTime CustomFormat: $'''yyyy/MM/dd(ddd)''' Result=> FormattedDateTime

-アクション, テキスト
-