cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Advocate IV
Advocate IV

string to date

Hello,

 

I've a date in a string as "2019-20-Feb" how to convert the string or change month in number Feb=2 ?

 

Thank you

Patrick

2 ACCEPTED SOLUTIONS

Accepted Solutions
Highlighted
Community Support
Community Support

Re: string to date

Hi @patrick_S_hexa ,

 

You could create a lookup table that stores the serial numbers for the twelve months in an Excel table or SharePoint list.

20.PNG

Expression:

last(split(outputs('Initial_Value'),'-'))
replace(outputs('Initial_Value'),last(split(outputs('Initial_Value'),'-')),body('Get_a_row')?['Number'])

Use the Split() function to get the month, then get the corresponding number from the Excel table, and replace the month with a number using the replace() function.

19.PNG

If you don't want to create additional tables, you could use Switch to list the twelve possible months and replace them with numbers.

An example of the replacement of Jan and Feb, the other can be configured as follows:

21.PNG

Please take a try.

 

Best Regards,

Community Support Team _ Barry
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

Highlighted
Advocate IV
Advocate IV

Re: string to date

Hello,
Thank you for the idea!
I've created a more simple way I think:

First I Compose a string with all values in header: Jan:01,Feb:02,Mar:03,Apr:04,May:05,Jun:06,Jul:07,Aug:08,Sep:09,Oct:10,Nov:11,Dec:12

Then I use this

substring(substring(outputs('Compose'),indexOf(outputs('Compose'),MonthText)),6),4,2)

 

Regards

Patrick

View solution in original post

2 REPLIES 2
Highlighted
Community Support
Community Support

Re: string to date

Hi @patrick_S_hexa ,

 

You could create a lookup table that stores the serial numbers for the twelve months in an Excel table or SharePoint list.

20.PNG

Expression:

last(split(outputs('Initial_Value'),'-'))
replace(outputs('Initial_Value'),last(split(outputs('Initial_Value'),'-')),body('Get_a_row')?['Number'])

Use the Split() function to get the month, then get the corresponding number from the Excel table, and replace the month with a number using the replace() function.

19.PNG

If you don't want to create additional tables, you could use Switch to list the twelve possible months and replace them with numbers.

An example of the replacement of Jan and Feb, the other can be configured as follows:

21.PNG

Please take a try.

 

Best Regards,

Community Support Team _ Barry
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

Highlighted
Advocate IV
Advocate IV

Re: string to date

Hello,
Thank you for the idea!
I've created a more simple way I think:

First I Compose a string with all values in header: Jan:01,Feb:02,Mar:03,Apr:04,May:05,Jun:06,Jul:07,Aug:08,Sep:09,Oct:10,Nov:11,Dec:12

Then I use this

substring(substring(outputs('Compose'),indexOf(outputs('Compose'),MonthText)),6),4,2)

 

Regards

Patrick

View solution in original post

Helpful resources

Announcements
FirstImage

Microsoft Ignite 2020

Check out the announcement of Power Platform content at Microsoft Ignite!

thirdImage

Experience what's new for Power Automate

Join us for an in-depth look at the new Power Automate features and capabilities at the free Microsoft Business Applications Launch Event.

firstImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Users online (5,157)