Do you want to convert a number to date in Power Automate? In this tutorial, we will see how to convert numbers to date in Power Automate.
Here, we will cover the topics below
- How to convert number to date in Power Automate
- How to convert integer to date in Power Automate
- How to convert serial number to date in Power Automate
Convert number to date in Power Automate
Here, we will see how to convert numbers to date in Power Automate.
For example, we have a number, i.e., 44307, and when we convert this number to the date format ‘dd-MMM-YY ‘, the result will be 21-Apr-2021.
To do this in Power Automate, follow the below steps:
1. Open Power Automate Cloud, click on +Create and select Instant Cloud Flow.
Then, provide the flow name and select Manually trigger a flow action. Then click on Create.
You can see the “Manually trigger a flow” action is added to the canvas. Next, click on +Add an input option -> select the ‘Number’ field.
2. We will convert this number to date; for this, click on +New step -> select Compose action. Then provide the below information:
- Inputs: Provide the below expression:
addDays('1899-12-30',triggerBody()['number'], 'dd-MMM-yyyy')
3. Now save the flow and run the flow manually. Then, enter the number you need to convert to date.
This is how to convert the number to date in Power Automate.
Convert integer to date in Power Automate
Here, we will see how to convert integers to date in Power Automate.
For example, we have a number of string type ‘44327’, and then we will convert it to date. We need to convert the string to date in Power Automate for this.
To do this in Power Automate, follow the below steps:
1. Open Power Automate Cloud, click +Create and select Instant Cloud Flow.
Then, provide the flow name and select Manually trigger a flow action. Then click on Create.
Now you can see the “Manually trigger a flow” action is added to the canvas in Power Automate. Next, click on Add an input -> select the Text icon to add a text field to the action.
2. We will convert this number to date; for this, click on +New step -> select Compose action. Then provide the below information:
- Inputs: Provide the below expression:
addDays('1899-12-30',int(triggerBody()['text']), 'dd-MMM-yyyy')
3. Now save the flow and run the flow manually. Then, enter the text you need to convert to date.
This is how to convert integers to date in Power Automate.
Convert serial number to date in Power Automate
Here, we will see how to convert serial numbers to date in Power Automate.
For example, we have an Excel sheet containing information related to Employee Birthdays. The columns are listed below.
- Employee Name
- Employee Email
- Employee DOB
We will get the information from Excel and write it into the SharePoint list i.e., Employee Birthday. Contains the below fields:
- Title: Single line of text
- Employee Name: Person
- Employee Email: Single line of text
- Employee DOB: Date and time
When we get the details from Excel, in Power Automate the employee DOB is coming in serial number like below.
So, here, we will create a flow in Power Automate that we will convert the number to date.
1. Open Power Automate Cloud, click +Create and select Instant Cloud Flow.
Then, provide the flow name and select the ‘Manually trigger a flow” action. Then click on Create.
Now you can see the “Manually trigger a flow” action is added to the canvas in Power Automate.
2. Next, we will get the information from the Excel sheet; click on the +New step -> select List rows present in a table action. Then, provide the information below.
- Location: Provide the Location of Excel
- Document Library: Provide the Document library where Excel is available
- File: Select the Excel file.
- Table: Select the table from the drop-down.
3. Next, initialize the variable that we will use. Store the date; for this, click on +New step -> select Initialize variable action. Then provide the below information:
- Name: Provide the name as the Date.
- Type: Select the type a string
4. Now, we will convert the number to date; for this, click on Add an action -> select Set variable action. Then provide the below information:
- Name: Select the variable name
- Value: Provide the value as an expression. Also, it will automatically add Apply to each action in Power Automate.
addDays('1899-12-30',int(items('Apply_to_each')?['Date Of Birth']),'yyyy-MMM-dd')
5. Now, we will create an item in the SharePoint list; for this, click on Add an action -> select Create item action. Then provide the below information:
- Site address: Provide the sharePoint site address
- List name: Provide the Sharepoint list name
- Title: Provide the expression as guid()
- Employee Name Claims: Provide the Employee name from dynamic content
- Employee Email: Provide the employee email from dynamic content.
- Employee DOB: Select the Date variable from dynamic content.
6. Now save the flow and then run the flow manually. The items are created in the SharePoint list, and the number is converted to date.
This is how to convert the number to date in Power Automate.
Conclusion
In this Power Automate tutorial, we saw how to convert a number to date in Power Automate.
You may also like:
- How to Format Numbers to Decimal Places Using Power Automate?
- Convert a Number to Hexadecimal in 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