Do you want to convert a SharePoint list string to date using Power Automate flow? Then, this Power Automate tutorial will guide you on how to convert the string to date for a SharePoint list using Power Automate with an example. By the end of the tutorial, you will learn how to convert a string to a (dd-MMMM-yy) date format in Power Automate.
Sometimes, users might enter the date value in a string format. In those cases, we need to convert the String date to the Date format that Power Automate will recognize. So here, I have explained clearly how to overcome this issue. If you follow the exact steps, I’m sure it will also work for you.
Scenario:
According to my requirement, I want to Convert String to Date for the SharePoint list. So, in my SharePoint list, I have two columns called Start Date and End Date, which are of String values.
Now, I have to convert the StartDate and End Date column values to the Date format from the String values for the SharePoint list using Flow.
The flow will trigger when a new item is added and sends an email to the Team Manager with the Project details and the date formatted values of the Start and End Date.
Before creating a flow, we have to create a SharePoint online list. In this example, I am going to use the Projects list consisting of below columns:
Column name | column Data Type |
Project Name | default title column |
Client | Single line of Text |
Team Manager | People or Group |
Status | choice type |
Start Date | Single line of Text |
End Date | Single line of Text |
Now, we will create a flow on converting string date values to date format date values and send an email when a new SharePoint list is added using Power Automate flow.
Convert String to Date for SharePoint list using Power Automate
Let us see how to convert String to Date for the SharePoint list using Power Automate Flow.
Step-1:
Create an automated cloud flow with the trigger when an item is created. Expand the trigger action and provide the required parameters.
- SharePoint Site Address – select the SharePoint site address from the dropdown.
- List Name – Select the SharePoint list (here, I have selected my Projects list)
Step-2:
Now in our SharePoint, the Start Date and End Date are text data types so the data values are stored as String.
So, we have to convert the string date value to Date format and notify the team manager regarding the project details.
To convert the string to date format, initially, we have split the values and concat them in the
yyyy -MM-dd format. Because the DateTime string must match ISO 8601 format, which is
yyyy-MM-dd.
Now convert the Start Date from the SharePoint list, which is of string value, to the Date format; for that add a compose data operation, and pass the below code under the expression tab as input.
split(split(triggerOutputs()?['body/StartDate'],'')[0],'/')
Where,
- Split – function
- StartDate – column internal name
Similarly, we have to convert the End Date from the SharePoint list, which is of string value, to the Date format; for that, add a compose data operation and pass the below code under the expression tab as input.
split(split(triggerOutputs()?['body/EndDate'],'')[0],'/')
Where,
- Split – function
- EndDate – column internal name
Step-3:
Now, we will use the concat function, to get the values in a yyyy-MM-dd format because the DateTime string must match ISO 8601 format yyyy-MM-dd in Power Automate flow.
So that we can use the format DateTime function to format the date values as per our requirement.
Here, add a compose data operation, and pass the below expression as input for StartDate string format, which concats the values based on the index of the output values in a (yyyy-MM-dd).
After that, using the format DateTime function here, I passed the format as (dd-MMMM-yyyy)
formatDateTime(concat(outputs('StartDate_-_StringFormat')[2],'-',outputs('StartDate_-_StringFormat')[1],'-',outputs('StartDate_-_StringFormat')[0]),'dd-MMMM-yyyy')
Similarly, add a compose data operation, and pass the below expression as input for EndDate string format, which concats the values based on the index of the output values in a (yyyy-MM-dd).
After that, using the format DateTime function here, I passed the format as (dd-MMMM-yyyy)
formatDateTime(concat(outputs('EndDate_-_StringFormat')[2],'-',outputs('EndDate_-_StringFormat')[1],'-',outputs('EndDate_-_StringFormat')[0]),'dd-MMMM-yyyy')
This will convert the String to Date in Power Automate.
Step-4:
Now to send an email to the team manager, Add a new step and select Send an email V2 action from action triggers.
- To: Select the Team Manager email address from the dynamic content
- Subject: Enter a subject line as Project Details.
- Body: Enter the Project details as below, and pass the values from the dynamic content.
Pass the output of converted date format values stored in the compose data operation for the Start Date and End Date.
Step-5:
Our complete flow looks like below:
The flow triggers automatically when a new item is added to the SharePoint list. Here I have added a new item to the SharePoint Project List as highlighted below:
Once the flow triggers automatically and runs successfully like below:
An Outlook email will be sent to the Team manager with the complete Project information. In the screenshot below, you can see that the string date values for StartDate and EndDate are converted as a date formatted and displayed in the values (dd-MMMM-yy) format.
This is how to convert String to Date for the SharePoint list using Power Automate Flow.
Conclusion
I hope you got a clear idea of how to convert string to date for the SharePoint list using Power Automate flow.
We also learned Power Automate requires a specific date format (yyyy-MM-dd format) to use the Format DateTime function in Power Automate.
Here, I have converted the string type of StartDate and EndDate column values presented in the SharePoint list to the Date format using the Format DateTime function and sent an email with the Formatted Date values for the StartDate and EndDate.
You may also like:
- The DateTime String must match ISO 8601 format error in Power Automate
- How to Format Numbers with Leading Zeros Using Power Automate?
- How to format a number as currency in Power Automate?
- Power Automate Number Format
- How to Format Numbers to Decimal Places Using Power Automate?
I am Bijay a Microsoft MVP (10 times – My MVP Profile) in SharePoint and have more than 17 years of expertise in SharePoint Online Office 365, SharePoint subscription edition, and SharePoint 2019/2016/2013. Currently working in my own venture TSInfo Technologies a SharePoint development, consulting, and training company. I also run the popular SharePoint website EnjoySharePoint.com