web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Setting the time porti...
Power Automate
Answered

Setting the time portion of a datetime variable

(0) ShareShare
ReportReport
Posted on by 27

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!

Categories:
I have the same question (0)
  • Community Power Platform Member Profile Picture
    on at

    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?

  • pbenati Profile Picture
    27 on at

    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.
  • Verified answer
    pbenati Profile Picture
    27 on at

    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

  • Community Power Platform Member Profile Picture
    on at

    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 Profile Picture
    on at

    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

     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 501 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 323 Moderator

#3
abm abm Profile Picture

abm abm 237 Most Valuable Professional

Last 30 days Overall leaderboard