Introduction:
In this blog, we will learn, how we can change the date and
time format in Microsoft Power Automate. Sometimes, there are situations in
which we need to change the format of the date and time value.
Let’s say for an example if our date time value is 2020-01-30T07:51:09Z and we wish to convert this value
to “01/30/2020 07:51:06 AM” format, then we need to use some expression in MS
Flow or Power Automate.
Real-Life Use Case:
In this article, we
will format the date and time value to “MM/dd/yyyy hh:mm:ss AM/PM” format for
SharePoint list item. We already have a SharePoint list with OOTB “Created”
column. We will change the format of Date and Time in Power Automate. So, now let’s get
started!
Step 1:
We have the following
list structure. and would need to convert "Created" column to “MM/dd/yyyy hh:mm:ss AM/PM”
format, and store this converted value in a variable.
Step 2:
Add a Trigger: When an item is created to the SharePoint list. Add Site Address and List Name.
Step 3:
Initialize variable, to store the value of the converted
date and time. Add an action: Initialize variable.
Step 4:
Now, let’s set the variable and change the date and time
format using below formula:
formatDateTime(triggerBody()?['Created'],'MM/dd/yyyy
hh:mm:ss tt')
Here, we need to pass, the date time value as a first
parameter and in the second parameter, we need to pass the format for the
specific date and time value.
Save the flow. We can check the formatted date and time
value from this variable.
In the end, MS flow will look like in the following
screenshot.
Now, let’s run the flow and check the result.
Test:
Let’s create one item in the SharePoint list to trigger a
flow.
Here, our date and time format for the “Created” date is changed and stored in the variable successfully.
Conclusion:
This is how, we can easily change the format for the date
and time column in Microsoft Power Automate. Isn’t it amazing?
If you have any questions you can reach out our SharePoint Consulting team here.
No comments:
Post a Comment