Power Automate End of Month and Start of Month with Recurrence Flow

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
in today's quick thursday tip we're going to talk about how to check to see if the date is the start of the month or the end of the month in power automate aka flow so just a quick one for right to make those recurring flows and just to help you guys understand a couple of the date functions as well so should be fun should be fast but first here's our intro hi my name is shane young with powerapps 911 those guys and today we're going to talk about end of the month and start of the month and some just different flow expressions for working with dates the reason for this is my buddy mark had this come up their days okay how do i get the end of the month and powerapps actually has a start of the month expression so we're like wait a minute and you know as well as things they just kind of snapped off the top of my head like that's kind of fun so i thought you guys would like to see it gives us a chance to talk about a couple business scenarios just overall some good learning so let's jump over there if you don't need to know how to do this i think there's a couple things you'll learn so let's have some fun all right so let's just start with a new flow right there's no reason to show you the working version of this because we're just going to write it so let's do a new flow and for the start here we're going to do we'll do a scheduled one right because this was mark's actual scenario he's like hey every morning i want to wake up i want to check to see if today is the last day of the month if it is i want to do a bunch of other stuff if it's not the last day of the month then i won't do anything so for that that is absolutely a scheduled flow over here in power automate the other thing i would remind you though if you just want to play and so when i had to just play to solve this for mark i made an instant flow that's usually where i like to play but since his scenario had this let's do this so scheduled flow and we'll just call this eom right end of month video [Music] yeah good enough so then when do i want to run this flow and i probably want to repeat once a day this is very typical of flows we write is wake up every day and check for something and if there's nothing to do then just don't do anything but this is how we often think about reoccurrence type of events um up here the starting time so if you want to have it start at a specific time you know it is currently 8 30 here so probably you know 10 o'clock sounds great so if we say create i want to talk about what this does so we chose 10. so if we go in here you can still edit this and remember we always talk about let powerapps or powerautomate do something for you then see how they did it to get some ideas so let's say show my advanced options and here you can see what they set up was an interval of once a day they didn't bother with the times and they just went with the start time but this is a ut utc start time so that's why even though i chose ten o'clock right it's set to uh 1500 which is three o'clock which is five hours ahead because 10 a.m eastern right i'm in eastern time zone is three o'clock utc so i've got a whole video on utc stuff if that like about your brain but in this case hopefully it doesn't just kind of keep in mind you can't play with this but that's not the point of the video so moving on all right so the first thing i want to do in this flow this is how it would go so i'm going to use my good friend compose just like i love labels and power apps i love compose inside of powerautomates and what we're going to do here is we're going to write our first function or expression i forget they call them expressions oh whatever so we're going over here to the right and we're going to say expression and if you scroll down you're going to find that they have a bunch of date and time functions and if we say see more they actually have one for start of the month right so what this will do is you give it a date and it tells you the start the first day of that particular month and so that's kind of what we want but we want the last day not the first day right so what we're going to do here so i'm going to throw this up here so give me the start of the month and for right now this is a flow that runs every day so i just want to check today so then we're going to use the utc now function as the date we pass it so if we do this this should return right today's february 18th so this will return february 1. make sense makes sense so that would get us february 1 okay but that's the start of the month we want the end of the month so what i've been trying to do is or you know there's probably seven ways to solve this honestly but the way that i came up with first was i wanted to do it this way so i'm going to another compose and for this compose we're going to do a very similar formula so let's do our whole we'll just start typing this time start a month and we want to but what we want to do is i want to see tomorrow this is how i decide to solve it so i said hey if whatever today's date is i want to go tomorrow's date and so if tomorrow's date's start of the month is different than today's start of the month then i know this was the end of the month right because on february 18th which is today you know start a month for that is february today plus one is february 19th start of the month is february so that tells me that today february 18th is not the start of the month but on february 28th right from february 28th and we get the start of the month that'd be february and february 28th plus one day is march 1st start of the month for that is march they wouldn't be equal i would know that today february 28th was the last day of the month so that was my twisted logic on how to solve this so to do that programmatically what i did was i said all right well i need to take start a month i need to use the add days function which allows me to add a day to a date what day do i want to follow you and your silly tool what day do i want to add a month to i want to add it to utc now right so that's right there and i want to add one day that's it right so that gives me today's start of the month and tomorrow's start of the month now one of the things you can also do here is rename these to make your life easier so i went up here i said rename and i said start a month or start a month today and then i went and renamed this one to start oh start of month tomorrow boom right because you want to just slide a little bit of documentation make sure it flows easier to read in six months we try to figure out what you did and so then finally we threw in a condition here so we said condition and what did we do we said if start of month today is equal to cursor right here start a month tomorrow so if those two are equal then that means it is not the end of the month so over here in the yes column i threw a compose actually i didn't throw it composed but i'm going to throw compose for you guys and just say not oh i can't spell not oh my goodness not the end of month right so not the end of the month and then we go over here and let's add an action over here and i would just say compose again is the last day of the month last day typing is hard of the month there you go so that should work so if we run this now we'll say save and then we'll do a test manually trigger it test the flow run the flow done runs almost instantly and if we go to condition we'll see that the output was true which is today is not the end of the month that's true february 18th is not the end of the month if you go back up here you can see the output so start a month for today was february 1st start of the month for tomorrow was february 1st so that's why they equalled right so so in this case we don't have to do anything now if you wanted to test it like shane are you sure you got this right that's a fair question i didn't know to screw up what you could do is you go cheat over here and so i know that 11 days from today would be march 1st right so let's just add 11 days to the date and say update and then do test and test and test and test and so this should say today is the end of the month right which it's not but it's you know what we're doing to fake the data there's other ways to fake this data i should probably do a video on that but that's a different story boom look at that condition is false compose it's not the last day of the month and the reason right february 1st and then march 1st so that's how we do it now if you're thinking about well shane this makes no sense right well i honestly i get that i didn't go all the way but so in mark's flow in this no column this is where we put all of his sql processing logic right all the things he wanted to happen on the last day of the month all is over here in this column and there's literally nothing in the s column for him because that was the business logic that he had now the other thing i want to point out real quick sharon on twitter reminded me to tell you guys you know this is pulling obviously against you know utc now so today's date uh tomorrow's date but think about utc especially if are you querying a data source to see if the date's the end of the month you might have to use one of those time zone functions that we've talked about before to convert it to your current time zone or at least factor in how utc might affect it so just keep that in mind this works straight up because this was the scenario mark wanted but to sharon's point if you were using this instead of based on utc today or utc now that you'd have to think a little bit harder about you know hitting the time zones and or not in the time zones the uh oh yeah the time zones right make sure utc wasn't messing with your head so but there you go i thought this was a fun little quick tip gave us a chance to look at some different functions and it's quite practical because this is something a lot of you have to do and remember if you had if you're just trying to start a month right so you've tried five today was the first day of the month you would do the same thing so is start of the month equal to today that's how i would think about that right i'd say is the start a month expression equal to just the utc now expression right are they the same yes they are then i know that uh today would be the start of the month if they're different then i wouldn't so if that's too not enough info leave me a comment below we'll make a video just specifically on start a month but i think that one's a lot easier to wrap your head around all right with that you know i'll just remind all you guys that you know i've got some upcoming training at a live class here in march 8th we're going to do dataverse for teams if you want to download this flow you can go to training.powerapps.com and powerups911.com and sign up for the curated library you can download the video you can download the um the flow all the apps i built right there's hundreds of videos out there at this point so cool all right with that i'm gonna say thanks and have a great day before you go be sure to click on the subscribe button over here so that way you'll be notified when new videos come out if you need any help you want to work together whether your problem is big or small check us out at powerapps911 we do it all i rhymed or if you're looking for more formal training offerings we have those linked up here somewhere so check them out thanks and have a great day
Info
Channel: Shane Young
Views: 22,097
Rating: undefined out of 5
Keywords: Shane Young, powerapps911, power automate, power automate tutorial, Microsoft flow, microsoft flow tutorial, power automate end of month, power automate EOM, power automate start of month, utcnow, startofmonth, adddays, power automate date functions, power automate dateadd, microsoft flow date, power automate compose, power automate compose action, power automate recurrence, power automate recurrence interval, jon levesque microsoft flow
Id: sNZXxJ-QrIE
Channel Id: undefined
Length: 11min 14sec (674 seconds)
Published: Thu Feb 18 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.