Showing results for 
Search instead for 
Did you mean: 

Time to make the donuts!

Hi, Flow fans! 


My name is Sandy Ussia, and this is my first post in the Flow Community blog, though I've been fairly active in the past year answering questions in the forums and speaking about Flow at SharePoint events. My favorite thing is puzzling out how to do something, as long as it can be done without getting into code Smiley Happy


I ran across this question in the Flow Community forums recently, and thought it was a very interesting problem: How can I run a Flow at sunrise each day? Perhaps you need a reminder of something each day based on the sunrise (or sunset)... milk the cows, say your prayers, make the donuts...whatever. It's simple enough to have a Flow run at a certain time each day, using the Recurrence trigger, but how to have it run based on a changeable thing like the time the sun rises wherever you happen to be?


The idea I had was to make use of the MSN Weather connector, which among other things can tell you the sunrise time today. So... every Flow must have a trigger of some sort, something that sets it off. Unfortunately, the two triggers available with the MSN Weather connector are only related to the current weather (i.e. When the current conditions change, and When the current weather changes). However, the sunrise and sunset times (and lots of other things) are available in the weather forecast coming from this connector. But that's an Action: Get forecast for today. Meaning it can only be used within a Flow that's already been triggered. So for a trigger, I chose Recurrence - what I did here was set it to trigger daily at some hour before sunrise, e.g. 4am. You just need to be sure to select your time zone (I happen to be in Costa Rica right now), and select an hour from the checkboxes it gives you in At these hoursDaily at 4a.png


Next is the MSN Weather action Get forecast for today. Here, you specify the location, and the unit of measure you want to use (Imperial or Metric, i.e. F vs C temp). You can just type in a city and country, or enter a longitude and latitude, or various other things (there's a tip in the box about that).Get forecast for today.png

This action returns all sorts of interesting information!  


In the next step, I found I needed to do a bit of trickery with the value that came back from MSN Weather for the sunrise time. It came back in a format like 2018-04-16T11:25:50+00:00, but the following step needed it to be in standard UTC format like 2018-04-16T11:25:50Z. So the Compose action uses an expression to modify the text: 


I created the expression by using the Expression Builder, but the above is what comes out of it. Basically, I'm getting the first 19 characters of the sunset time, i.e. removing the +00:00 from the end. In Expression Builder, I selected the substring function, and then inside the () I went back to Dynamic Data and selected the Sunrise time from the Get forecast for today action. The substring function then requires a beginning position (0 in this case, for the first character) and a number of characters after that (19 in this case, counting the characters up to the + in the datetime coming back from MSN Weather).



Compose sunrise time.png



The next action is Delay Until, which pauses the Flow until a certain time. Here, the time is the Output of the Compose step, with a Z added to the end to meet the format requirement.Delay until sunrise.png


Something to be aware of is that all datetime outputs of a Flow action are in UTC time. So while the sunrise value of the MSN Weather action was 11:25, that equated to the actual sunrise time here in Costa Rica of 5:25am.


And then after that you can do whatever actions you want to do. I just sent myself a mobile notification, which buzzed my phone at 5:25am as the sun was coming up over the mountains and the birds were singing Smiley Happy


Send notification.png

So here's an overview of this Flow... Trigger on sunrise overview.png




I hope this has been useful to get you thinking of some other similar scenarios when there isn't the exact trigger available that you need.



Hello Sandy!


I was creating my own Flow that would send a notification at sun rise and sunset just to test out the parrallel branches. When my flow failed because of the timestamps not being in the proper format I looked to the community and found your solution. As I was editing mine to reflect your solution, I thought of a way to possibly simplifiy it another step.

composing_versus_concatenation.PNG For sunrise's alert I have your suggested solution of composing the substring and then having delay until call on the substring. On sunset's side of the Flow I used 

concat(substring(body('Get_forecast_for_today')?['responses']?['almanac']?['sunset'],0,19), 'Z')

to add the 'Z' to the rest of the timestamp all at once. 
Just thought I'd share back with you!

Nice, @Anonymous 🙂

Oh, hey! You're from near my hometown of Pittsburgh! (though technically I no longer live there)

Meet Our Blog Authors
  • Working daily with Microsoft Cloud to deliver the needs of my company, my customers and various Microsoft communities and forums. | Office 365 | Flow | PowerShell | PowerApps | SharePoint |
  • Co-founder of, Office 365 and SharePoint expert. Passionate about design and development of easy to use, convenient and flexible products.
  • Microsoft Business Apps MVP. Owner of ThriveFast, an Office 365 consulting company.
  • 7x Microsoft Business Solutions MVP (CRM)
  • I'm keen in MS technologies, SharePoint, Office 365 and development for them
  • Daniel is a Business Productivity Consultant & Microsoft Business Solutions MVP who is very enthusiastic about all things Office 365, Microsoft Flow, PowerApps, Azure & SharePoint (Online). Since the preview, Daniel has been working with Microsoft Flow and later on with Microsoft PowerApps. That led to him being awarded an MVP Award for Business Solutions. He loves to blog, present and evangelize about improving productivity in the modern workspace with these amazing tools!
  • Michelle is an Office 365 solution architect in Twin Cities, MN. She has been delivering business collaboration solutions for years with her focus on SharePoint and Office 365. Michelle is a recent board member of the Minnesota Office 365 User Group and has been a member of the SharePoint community since 2009. She is a frequent speaker at MNSPUG and SharePoint Saturday and co-chaired the Legal SharePoint User Group for 4 years. Her most frequent projects have involved rolling out a large deployment of Office 365, SharePoint Online intranet, build of a "CHAMPS" Office 365 user adoption program and most recently, SharePoint On-Premise to Online Migration. Michelle is very excited about cloud technology as it is shifting her IT Pro focus to collaboration strategy and technical adoption.
  • I'm a Microsoft Office Servers and Services MVP with a special interest in SharePoint, Office 365, Microsoft Flow, Microsoft Teams and PowerApps. I work at Triad Group Plc (
  • Passionate #Programmer #SharePoint #SPFx #Office365 #MSFlow | C-sharpCorner MVP | SharePoint StackOverflow, Github, PnP contributor