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

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
Community Support Team
Community Support Team

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

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
Community Support Team
Community Support Team

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

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

New Ranks and Rank Icons in April

Read the announcement for more information!

firstImage

Better Together Contest Finalists Announced!

Congrats to the finalists of our ‘Better Together’-themed T-shirt design contest! Click for the top entries.

firstImage

New & Improved Power Automate Community Cookbook

We've updated and improved the layout and uploading format of the Power Automate Cookbook!

thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Community Summit North America

The top training and networking event across the globe for Microsoft Business Applications

Top Solution Authors
Top Kudoed Authors
Users online (8,028)