cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
pbenati
Advocate II
Advocate II

Setting the time portion of a datetime variable

All,

 

In my Flow (triggered from a PowerApp) I'm creating a SharePoint Calendar List item.  As part of the item I want the Start Time to be the passed in via the PowerApp StartDate whereby the time portion of the datetime is:  "00:00:00Z".  Similarly, I want the End Time to be the passed in via the PowerApp StartDate whereby the time portion of the datetime is:  "23:59:59Z".  This will create an "all-day" entry on the SharePoint calendar.  How do I make this happen?

 

Note:  keep in mind I don't know whether or not the PowerApp StartDate provided has any time associated with it.  It might be zeros and then again it might be some randon time of a day.

 

Example:

  • PowerApp inputed StartDate is:  2018-01-24T12:00:34
  • I want the Create item Start Time field to be set to:  2018-01-24T00:00:00Z
  • I want the Create item End Time field to be set to:  2018-01-24T23:59:59Z

 

I've tried to do all sorts of string manipulation as well as applying datetime funcitons like addHours, addMinutes, and addSeconds.  Nothing seems to work.

 

HELP, thanks!

1 ACCEPTED SOLUTION

Accepted Solutions

Looks like I finally cracked the code!  Here's what finally got it working...

 

TempString = addDays(triggerBody()?['Start_x0020_date'],variables('PRCount'))

StartDate = convertToUtc(variables('TempString'),variables('PST'))

TempString2 = concat(substring(variables('TempString'),0,indexOf(variables('TempString'),'T')),'T23:59:59')

EndDate = convertToUtc(variables('TempString2'),variables('PST'))

 

Screen Shot 2018-01-25 at 4.47.32 PM.png

View solution in original post

5 REPLIES 5
kelliprieto
Advocate II
Advocate II

I have experimented with custom date/time formats for different use cases, including all day events, but our applications of these features may be different.

 

I am not sure I follow exactly what you're trying to do - are you trying to add an all-day event to a SharePoint Calendar by manually triggering a Microsoft Flow? 

 

Could you share screenshots of your Flow?

Screen Shot 2018-01-25 at 3.54.42 PM.png

 

The date from the PowerApp is:  triggerBody()?['Start_x0020_date']

 

StartDate = 

convertToUtc(concat(addDays(triggerBody()?['Start_x0020_date'],variables('PRCount')),'T00:00:00Z'),variables('PST'),'yyyy-MM-dd:Thh:mm:ssZ')
 
EndDate = 
convertToUtc(concat(addDays(triggerBody()?['Start_x0020_date'],variables('PRCount')),'T23:59:59Z'),variables('PST'),'yyyy-MM-ddThh:mm:ssZ')
 
PRCount is originally set to zero and then incremented by 1 each time through the do...until loop until PRCount gets to the number of days of PTO requested.

Looks like I finally cracked the code!  Here's what finally got it working...

 

TempString = addDays(triggerBody()?['Start_x0020_date'],variables('PRCount'))

StartDate = convertToUtc(variables('TempString'),variables('PST'))

TempString2 = concat(substring(variables('TempString'),0,indexOf(variables('TempString'),'T')),'T23:59:59')

EndDate = convertToUtc(variables('TempString2'),variables('PST'))

 

Screen Shot 2018-01-25 at 4.47.32 PM.png

View solution in original post

Nice! 

 

Usually, I receive error messages that require all day events to have start and end times that add up to 24 hours.

v-xida-msft
Community Support
Community Support

Hi @pbenati,

 

Have you solved your issue on your side?

 

You could also consider take a try to achieve your needs with the following workaround:

  • Add a proper trigger, here I use Flow Button trigger.
  • Add a Variables-> "Initialize variable" action, Name set to StartDate, Type set to Sting and Value set to following formula:
2018-01-24T12:00:34

Note: I use the StartDate variable to instead of the PowerApps app inputed StartDate on my side.

  • Add a Compose action, rename it as "Start Time", Inputs set to the following formula:
  • concat(substring(variables('StartDate'),0,indexOf(variables('StartDate'),'T')),'T00:00:00Z')
    Add a Compose 2 action, rename it as "End Time", Inputs set to following formula:
concat(substring(variables('StartDate'),0,indexOf(variables('StartDate'),'T')),'T23:59:59Z')

Image reference:15.JPG

The flow works successfully as below:16.JPG

 

 

Best regards,

Kris

 

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

Helpful resources

Announcements
2022 Release Wave 1 760x460.png

2022 Release Wave 1 Plan

Power Platform release plan for the 2022 release wave 1 describes all new features releasing from April 2022 through September 2022.

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Top Solution Authors
Top Kudoed Authors
Users online (2,982)