Skip to main content

Format the date to a specific format

Power Automate Desktop has an action to get the current date, so it can be easily obtained, but if you want to operate the acquired date, you will need to devise it.

Also, if the current date is obtained, the created variables are stored as DateTime type, so you must be careful when using it.

This time, I will explain how to format date data into a specific format.

Datetime conversion

The DateTime type is an object with multiple properties, and you can get the date -related data by specifying the%variable name .year%.

However, if you use it as a string, a format is required, and format using the action "Convert DateTime into text".

The format format is basically unnecessary because the format is prepared to some extent, but if you need your own format, you will use a specific alphabet as follows.

labelscontent
yyyyyear
MMmoon
dddate
HHtime
mmMinute
sssecond
ffmillisecond
zzzUTC offset

implemented with copy and paste

Copy the following code and paste it on the edit screen of Power Automate Desktop to add the target action.

DateTime.GetCurrentDateTime.Local DateTimeFormat: DateTime.DateTimeFormat.DateAndTime CurrentDateTime=> Current
Text.ConvertDateTimeToText.FromCustomDateTime DateTime: Current CustomFormat: $'''yyyy/MM/dd HH:mm:ss.fff zzz''' Result=> Formatted

Power Automate Desktop is implemented

  1. Enter "Acquisition of the current date" from "Search Action" and set the property as follows.

    Parameter namevalue
    ObtainCurrent date
    Time zoneSystem time zone
    Generated variables%Current%
  2. Similarly, enter "Convert DateTime into text" from "Action Search" and set it as follows.

    Parameter namevalue
    Convert DateTime%Current%
    Format to be usedcustom
    Custom formatyyyy/MM/dd HH:mm:ss.fff zzz
  3. By setting and executing the format you want to use "Custom format", the current date can be displayed in any format.