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.
labels | content |
---|---|
yyyy | year |
MM | moon |
dd | date |
HH | time |
mm | Minute |
ss | second |
ff | millisecond |
zzz | UTC 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
Enter "Acquisition of the current date" from "Search Action" and set the property as follows.
Parameter name value Obtain Current date Time zone System time zone Generated variables %Current% Similarly, enter "Convert DateTime into text" from "Action Search" and set it as follows.
Parameter name value Convert DateTime %Current% Format to be used custom Custom format yyyy/MM/dd HH:mm:ss.fff zzz By setting and executing the format you want to use "Custom format", the current date can be displayed in any format.