Hello,
I have developed a flow that successfully imports excel data to a SharePoint list. The last step I need to complete is to update the year in the date column to match the day of the date. Basically when the user exports the excel sheet from its original data source, the source only gives the month and day in the date column, so excel assumes year is current year to fill in the blank. I know it sounds funny but stick with me!
For example, if I have a date in the date column that is 9/22/2023, I need to year to say 2022, not 2023. I know this change could take place within the excel sheet before import, but I am trying to save formatting steps for the end user.
So far in my flow I have a get items step which gets all the items I need to update, then an apply to each. Within the apply to each I have an update item step, and this is where I get stuck because I am not sure how to manipulate the date to update it as mentioned above.
Any help would be greatly appreciated!
Solved! Go to Solution.
Ok, so I am using the dd day value to be the last two digits of the year. I will combine 20 with the dd so that it will be basically like 20dd.
Then I put the whole thing together with the 'MM-dd' from the original date. I keep the same dd value since it doesn't matter. If you want to change the dd, you could type in 01 or whatever you prefer.
Basic expression to create year:
concat('20',formatDateTime(variables('SPAsOfDate'),'dd'))
Full expression to make a date value (basic expression is inside this):
concat(concat('20',formatDateTime(variables('SPAsOfDate'),'dd')),'-',formatDateTime(variables('SPAsOfDate'),'MM-dd'))
Here I am using a variable named SPAsOfDate in my example.
And the results format the date to be 2019 since the day date was the 19th.
Can you use that example in your apply to each and get the updates?
So you just need to change the year from 2023 to 2022?
There are no dates that need to be 2021 or 1998 or anything? And you don't plan on running this next year or ongoing?
I have a SharePoint list which has a DateTime type column. If I wanted to subtract the year by 1, I would use the expression below.
concat(string(sub(int(formatDateTime(items('Apply_to_each')?['StatusUpdateDateTime'],'yyyy')),int(1))),'-',formatDateTime(items('Apply_to_each')?['StatusUpdateDateTime'],'MM-dd'))
This basically says, take the current datetime from the column and format formatDateTime() it to be just the year 'yyyy'. Convert that 'yyyy' to an integer/number int(). Subtract sub() 1 from that number. Then convert this into a text string().
Then formatDateTime() the column to just have the month and date 'MM-dd' which will be a text string.
Concatenate concat() these two things together along with an extra '-' dash.
Since I have blanks in my SharePoint list, I needed to add the if() and empty() functions to check the field first. So it won't try to run the expression on the empty field and cause an error.
if(empty(items('Apply_to_each')?['StatusUpdateDateTime']),null,concat(string(sub(int(formatDateTime(items('Apply_to_each')?['StatusUpdateDateTime'],'yyyy')),int(1))),'-',formatDateTime(items('Apply_to_each')?['StatusUpdateDateTime'],'MM-dd')))
Let me know if this works for you
Thanks for your quick reply @wskinnermctc ! Your question, "There are no dates that need to be 2021 or 1998 or anything? And you don't plan on running this next year or ongoing?" is a very good point and one that I should clarify with the end user. I know we don't have data going back to years, however I believe there is data going back a few years at least.
I also believe I may have explained something incorrectly in my original post; However, I plan to meet with the end user tomorrow so I will gain more clarity on this topic and post back to this thread ASAP.
Yeah the first problem is that Excel data that doesn't have the year.
I don't know how you plan on interpreting the year when only having the Month and Day.
Like I hard coded 1 year by subtracting 1. But that will just do it for all of the dates.
Honestly, the data should be corrected from the source output, (not saying modify it in the excel), like there should be an extra column or something when the excel is created. The user wouldn't have to format anything. The source output would provide the information.
I don't care how the source outputs the info, obviously a regular date column is ideal, but it could just have the year or whatever, but something to reference and use within power automate.
@wskinnermctc Apologies for the delayed reply. I had my original explanation backwards. The original data source exports to excel with the month and two-digit year. Excel assumes the two-digit year is the day and uses the current year to fill in the blank to complete the date format.
For my use case the date (day) doesn't matter. I am really only concerned with getting the month and year correct. So essentially, I want to keep the month that is given, hardcode the date to anything (say 01), but use the two-digit year as mentioned above and concat that with the first two digits of the current year. Below is a snapshot of what I have tried to do along with the formula I tried to write for it (inspired by your formula from your previous post), but I am getting the error "String was not recognized as a valid DateTime."
I know this one is a crazy one and really do appreciate any further help you can provide on this! I do believe this use case is a one off.
formula in the AsOfDate of the apply to each:
This isn't that crazy, but I need to see the data to understand better. Right now I can't tell what could be causing the error.
Can you put a Compose step in your flow before the Update Item. Put the AsOfDate into it without any changes into the Compose. Put a second Compose under it and put your Concat formula that you are using in the Update item. Run the flow and show me a couple of the outputs of the two separate compose. That way I can see the original value as well as what the Concat is doing.
Also show a screenshot of the SharePoint list column with the date values.
I'm a little turned around about what values are being used, so if I can see them I could easily make an expression.
For a date to be accepted in SharePoint DateTime column it needs to be in the "yyyy-MM-dd" format. If you format a date as "MM-dd-yyyy" or "yyyy/MM/dd" or anything else other than "yyyy-MM-dd" will be an error since the column can't accept it.
@wskinnermctc Thanks again for your reply! Out of respect for your time I hope I provided what you need first shot. Below are the compose steps you requested. First one is the date that comes in from the get items with nothing done to it. The second is the compose action that had my last expression in it. I had the get item step return only one item for troubleshooting purposes as I am working with a large data set.
Also, in the screen shot on the right is the AsOfDate column as it appears in my SharePoint list. You'll notice the first date reflects what is in the first compose action. Additionally, I took a screen shot of many dates to show that you will see dates (the 2 digit day) of 21 and 22. So, the year should show as 2022 or 2021, not 2023...no change to the month...date can be any day of the month (I would say any date of 1-28 since every month has 28 days it in at minimum).
Ok, so I am using the dd day value to be the last two digits of the year. I will combine 20 with the dd so that it will be basically like 20dd.
Then I put the whole thing together with the 'MM-dd' from the original date. I keep the same dd value since it doesn't matter. If you want to change the dd, you could type in 01 or whatever you prefer.
Basic expression to create year:
concat('20',formatDateTime(variables('SPAsOfDate'),'dd'))
Full expression to make a date value (basic expression is inside this):
concat(concat('20',formatDateTime(variables('SPAsOfDate'),'dd')),'-',formatDateTime(variables('SPAsOfDate'),'MM-dd'))
Here I am using a variable named SPAsOfDate in my example.
And the results format the date to be 2019 since the day date was the 19th.
Can you use that example in your apply to each and get the updates?
@wskinnermctc Yes it worked, thank you! I also put the expression in the update item step and it updated the item on SharePoint. It appears I was on the right track but drastically over though the process. This has been a great learning experience as I am new to power automate. Auto sending email is about all that I have done until this.
I will mark your response as the solution.
Always something new to learn. Just keep trying things and eventually it will be a lot easier once you know how things work together.
Dear Community Members, We'd like to let you know of an upcoming change to the community platform: starting July 16th, the platform will transition to a READ ONLY mode until July 22nd. During this period, members will not be able to Kudo, Comment, or Reply to any posts. On July 22nd, please be on the lookout for a message sent to the email address registered on your community profile. This email is crucial as it will contain your unique code and link to register for the new platform encompassing all of the communities. What to Expect in the New Community: A more unified experience where all products, including Power Apps, Power Automate, Copilot Studio, and Power Pages, will be accessible from one community.Community Blogs that you can syndicate and link to for automatic updates. We appreciate your understanding and cooperation during this transition. Stay tuned for the exciting new features and a seamless community experience ahead!
We are excited to announce the Summer of Solutions Challenge! This challenge is kicking off on Monday, June 17th and will run for (4) weeks. The challenge is open to all Power Platform (Power Apps, Power Automate, Copilot Studio & Power Pages) community members. We invite you to participate in a quest to provide solutions to as many questions as you can. Answers can be provided in all the communities. Entry Period: This Challenge will consist of four weekly Entry Periods as follows (each an “Entry Period”) - 12:00 a.m. PT on June 17, 2024 – 11:59 p.m. PT on June 23, 2024 - 12:00 a.m. PT on June 24, 2024 – 11:59 p.m. PT on June 30, 2024 - 12:00 a.m. PT on July 1, 2024 – 11:59 p.m. PT on July 7, 2024 - 12:00 a.m. PT on July 8, 2024 – 11:59 p.m. PT on July 14, 2024 Entries will be eligible for the Entry Period in which they are received and will not carryover to subsequent weekly entry periods. You must enter into each weekly Entry Period separately. How to Enter: We invite you to participate in a quest to provide "Accepted Solutions" to as many questions as you can. Answers can be provided in all the communities. Users must provide a solution which can be an “Accepted Solution” in the Forums in all of the communities and there are no limits to the number of “Accepted Solutions” that a member can provide for entries in this challenge, but each entry must be substantially unique and different. Winner Selection and Prizes: At the end of each week, we will list the top ten (10) Community users which will consist of: 5 Community Members & 5 Super Users and they will advance to the final drawing. We will post each week in the News & Announcements the top 10 Solution providers. At the end of the challenge, we will add all of the top 10 weekly names and enter them into a random drawing. Then we will randomly select ten (10) winners (5 Community Members & 5 Super Users) from among all eligible entrants received across all weekly Entry Periods to receive the prize listed below. If a winner declines, we will draw again at random for the next winner. A user will only be able to win once overall. If they are drawn multiple times, another user will be drawn at random. Individuals will be contacted before the announcement with the opportunity to claim or deny the prize. Once all of the winners have been notified, we will post in the News & Announcements of each community with the list of winners. Each winner will receive one (1) Pass to the Power Platform Conference in Las Vegas, Sep. 18-20, 2024 ($1800 value). NOTE: Prize is for conference attendance only and any other costs such as airfare, lodging, transportation, and food are the sole responsibility of the winner. Tickets are not transferable to any other party or to next year’s event. ** PLEASE SEE THE ATTACHED RULES for this CHALLENGE** Week 1 Results: Congratulations to the Week 1 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge. Community MembersNumber SolutionsSuper UsersNumber Solutions Deenuji 9 @NathanAlvares24 17 @Anil_g 7 @ManishSolanki 13 @eetuRobo 5 @David_MA 10 @VishnuReddy1997 5 @SpongYe 9JhonatanOB19932 (tie) @Nived_Nambiar 8 @maltie 2 (tie) @PA-Noob 2 (tie) @LukeMcG 2 (tie) @tgut03 2 (tie) Week 2 Results: Congratulations to the Week 2 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge. Week 2: Community MembersSolutionsSuper UsersSolutionsPower Automate @Deenuji 12@ManishSolanki 19 @Anil_g 10 @NathanAlvares24 17 @VishnuReddy1997 6 @Expiscornovus 10 @Tjan 5 @Nived_Nambiar 10 @eetuRobo 3 @SudeepGhatakNZ 8 Week 3 Results: Congratulations to the Week 3 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge. Week 3:Community MembersSolutionsSuper UsersSolutionsPower Automate Deenuji32ManishSolanki55VishnuReddy199724NathanAlvares2444Anil_g22SudeepGhatakNZ40eetuRobo18Nived_Nambiar28Tjan8David_MA22 Week 4 Results: Congratulations to the Week 4 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge. Week 4:Community MembersSolutionsSuper UsersSolutionsPower Automate Deenuji11FLMike31Sayan11ManishSolanki16VishnuReddy199710creativeopinion14Akshansh-Sharma3SudeepGhatakNZ7claudiovc2CFernandes5 misc2Nived_Nambiar5 Usernametwice232rzaneti5 eetuRobo2 Anil_g2 SharonS2
On July 16, 2024, we published the 2024 release wave 2 plans for Microsoft Dynamics 365 and Microsoft Power Platform. These plans are a compilation of the new capabilities planned to be released between October 2024 to March 2025. This release introduces a wealth of new features designed to enhance customer understanding and improve overall user experience, showcasing our dedication to driving digital transformation for our customers and partners. The upcoming wave is centered around utilizing advanced AI and Microsoft Copilot technologies to enhance user productivity and streamline operations across diverse business applications. These enhancements include intelligent automation, AI-powered insights, and immersive user experiences that are designed to break down barriers between data, insights, and individuals. Watch a summary of the release highlights. Discover the latest features that empower organizations to operate more efficiently and adaptively. From AI-driven sales insights and customer service enhancements to predictive analytics in supply chain management and autonomous financial processes, the new capabilities enable businesses to proactively address challenges and capitalize on opportunities.
We're embarking on a journey to enhance your experience by transitioning to a new community platform. Our team has been diligently working to create a fresh community site, leveraging the very Dynamics 365 and Power Platform tools our community advocates for. We started this journey with transitioning Copilot Studio forums and blogs in June. The move marks the beginning of a new chapter, and we're eager for you to be a part of it. The rest of the Power Platform product sites will be moving over this summer. Stay tuned for more updates as we get closer to the launch. We can't wait to welcome you to our new community space, designed with you in mind. Let's connect, learn, and grow together. Here's to new beginnings and endless possibilities! If you have any questions, observations or concerns throughout this process please go to https://aka.ms/PPCommSupport. To stay up to date on the latest details of this migration and other important Community updates subscribe to our News and Announcements forums: Copilot Studio, Power Apps, Power Automate, Power Pages