cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
AlanJ
Level: Powered On

How do I Convert Time String (2:00 PM) to 24 hour time (14:00:00)?

Unfortuantely I am using a Microsoft Form as the intial input for colleciton of flows, and selecting a time isn't possible the way it is with dates. I am trying to automate the creation of events from sharepoint, but in order to do so, I need a yyyy-mm-ddThh-mm-ss format. Is there a simple way to do this? Or a better way to create events? I feel like I am so deep in the trees here I can't see the forest.

 

Thank you!

1 ACCEPTED SOLUTION

Accepted Solutions
Super User
Super User

Re: How do I Convert Time String (2:00 PM) to 24 hour time (14:00:00)?

Hi @AlanJ

 

In the expression you have, just change the hh to HH and leave the rest the same. This will give you the 24-hour format. See below:

formatDateTime(utcNow(),'HH:mm:ss')

24-hour.JPG


Fausto Capellan, Jr


Did I answer your question? Mark my post as a solution! Did my response help? Please give it a thumbs up!

Proud to be a Flownaut!


View solution in original post

11 REPLIES 11
Super User
Super User

Re: How do I Convert Time String (2:00 PM) to 24 hour time (14:00:00)?

Hi @AlanJ

 

You can try the following expression. Replace the utcNow() with your actual date/time column. As for the 's' inside the expression, the link below the code is a Format Specifier for Standard Date and Time Format Strings.

formatDateTime(utcNow(),'s')

 Standard Date and Time Format Strings


Fausto Capellan, Jr


Did I answer your question? Mark my post as a solution! Did my response help? Please give it a thumbs up!

Proud to be a Flownaut!


Highlighted
AlanJ
Level: Powered On

Re: How do I Convert Time String (2:00 PM) to 24 hour time (14:00:00)?

Thank you!

 

I have been playing with this and I am very close I think. I am using

 

formatDateTime('myvalue', 'hh:mm:ss')

 

The problem is, 3:00 PM is converting to 03:00:00, not 15:00:00. Any suggestion on that? Once that's fixed I am good to go. Thank you again for your help!

Super User
Super User

Re: How do I Convert Time String (2:00 PM) to 24 hour time (14:00:00)?

Hi @AlanJ

 

In the expression you have, just change the hh to HH and leave the rest the same. This will give you the 24-hour format. See below:

formatDateTime(utcNow(),'HH:mm:ss')

24-hour.JPG


Fausto Capellan, Jr


Did I answer your question? Mark my post as a solution! Did my response help? Please give it a thumbs up!

Proud to be a Flownaut!


View solution in original post

AlanJ
Level: Powered On

Re: How do I Convert Time String (2:00 PM) to 24 hour time (14:00:00)?

Thank you so much for your help! It works perfectly. This saved me a lot of headache.

Super User
Super User

Re: How do I Convert Time String (2:00 PM) to 24 hour time (14:00:00)?

Glad I could help.


Fausto Capellan, Jr


Did I answer your question? Mark my post as a solution! Did my response help? Please give it a thumbs up!

Proud to be a Flownaut!


Kyle461
Level: Powered On

Re: How do I Convert Time String (2:00 PM) to 24 hour time (14:00:00)?

Bringing up an old topic here, but can you post snippets of where you put the expression formatDateTime(utcNow(),'HH:mm:ss')?

 

 

I'm fairly new to Flow and am having the same issue when it comes to creating an event in the calendar. I want people to be able to just put in standard time and not military time. Here's my flow....

 

flow.JPG

Super User
Super User

Re: How do I Convert Time String (2:00 PM) to 24 hour time (14:00:00)?

Hello @Kyle461

 

Based on your screenshot, I will assume you are having this issue in the "Create event (V2)" step. Are you working with both date and time or just time? If you can expand the "Create event (V2)" step and upload a screenshot of that, I can point out where to add the expression.

One thing I must point out: the expression used to solve the original issue is just using time, but the user wanted military format. For standard time, the expression would be as follows: 

formatDateTime(utcNow(),'hh:mm:ss')

Fausto Capellan, Jr


Did I answer your question? Mark my post as a solution! Did my response help? Please give it a thumbs up!

Proud to be a Flownaut!


Kyle461
Level: Powered On

Re: How do I Convert Time String (2:00 PM) to 24 hour time (14:00:00)?

@faustocapellanj Thanks for the quick response!! I'm racking my brain here with the power of Flow and options.

 

Here's the expanded view of the "Create Event (V2)" section. Any suggestions are greatly appreciated. Basically what I want to happen is the user to put in standard time and the event to be recorded in military time since that's the only way it will be accepted and automatically put into the calendar. 

 

create event.JPG

Super User
Super User

Re: How do I Convert Time String (2:00 PM) to 24 hour time (14:00:00)?

Hi @Kyle461,

 

If you are forcing the users to use military time format in the Start Time field, you don't need to format, but if that's not the case, then the formatting must be done. The expression below was used in the Start Time and End Time fields. I will break down the expression so you can understand it better.

concat(body('Get_response_details')?['r562e2ac2239249c9adc16e60d4325ab4'],'T',formatDateTime(body('Get_response_details')?['r20ddd94fc1b74b1cad2d54a85b3a88eb'],'HH:mm:ss'))

To get started with the expression above, click in the Start time field and select the Expression tab next to the Dynamic content.

TimeString-1.JPG

Once in there, you can type concat or select it from the list. Click inside the parenthesis for concat(), go back to the Dynamic content tab and select the Request Date field. It will look like this in the expression: body('Get_response_details')?['r562e2ac2239249c9adc16e60d4325ab4']. 

After this bracket ], add the following ,'T',. After the last comma, enter the formatDateTime() expression and inside the parenthesis, select the Start Time from the Dynamic content, followed by this ,'HH:mm:ss' and then click OK.

 

Do the same thing for the End time field, but with the respective fields from the form. Please let me know the results.

 

Thanks,

Fausto Capellan, Jr

 


Fausto Capellan, Jr


Did I answer your question? Mark my post as a solution! Did my response help? Please give it a thumbs up!

Proud to be a Flownaut!


Kyle461
Level: Powered On

Re: How do I Convert Time String (2:00 PM) to 24 hour time (14:00:00)?

@faustocapellanj

 

It worked! You're awesome!

 

I even tested it out with users inputting PM or AM and it runs just as well. 

 

Thank you again!

Super User
Super User

Re: How do I Convert Time String (2:00 PM) to 24 hour time (14:00:00)?

You're welcome @Kyle461


Fausto Capellan, Jr


Did I answer your question? Mark my post as a solution! Did my response help? Please give it a thumbs up!

Proud to be a Flownaut!


Helpful resources

Announcements
firstImage

New & Improved Power Automate Community Cookbook

We've updated and improved the layout and uploading format of the Power Automate Cookbook!

thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

firstImage

Incoming: New and improved badges!

We've given our badges an overhaul and also added some brand new ones!

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

sixthImage

Power Platform World Tour

Find out where you can attend!

seventhimage

Webinars & Video Gallery

Watch & learn from the Power Automate Community Video Gallery!

Top Solution Authors
Top Kudoed Authors (Last 30 Days)
Users online (3,951)