I would like to convert the time format from 12 hours to 24 hours


I have date vtime = “5:35:50 AM”

Now I want to convert this to 24hours format.

I have tired the following : vtime.tostring("HH:mm:ss) but it gives and error called
Option strict on disallows implicit conversion from string to system.ioFormatProvider.


1 Like

Hi @satish_kumar ,

Could you try this?


DateTime.ParseExact("5:35:50 AM","h:mm:ss tt",Nothing).ToString("HH:mm:ss")

Kind Regards,
Ashwin A.K

Hi @satish_kumar ,

As the input time is in String format, We first would have to Convert it to Time format and then convert it to the 24 Hrs format.

Or we could do the below for a Faster approach :

DateTime.Parse("5:35:50 AM").ToString("HH:mm:ss")

Please do note that AM will keep the 5 as it is, while PM will convert it to the 24 Hr format i.e 17

HI @satish_kumar

Try this below expression

CDate("4:35:50 PM").ToString("HH:mm:ss")



1 Like


Let’s take you have string in an input string variable named strinput

Use a assign activity like this

stroutput = DateTime.ParseExact( strinput.padleft(11,CChar(“0”)),“hh:mm:ss tt”,System.Globalization.CultureInfo.InvariantCulture).ToString(“HH:mm:ss”)

The reason why I have pad left is what if time is 10:12:34

Now you have the time format set as h:mm:ss
If it comes in this format hh:mm:ss

Then it has to manage that also

So the above expression will cover all the scenarios

For more details on DateTime

Cheers @satish_kumar

1 Like

Datetimes don’t have formats. They’re stored as milliseconds since Jan 1 1970. You only see a format when you output them as strings.

Hi @satish_kumar

Kindly try the below expression

Datetime.ParseExact(“05:35:10 PM ”,“hh:mm:ss tt ”,new system.Globalization.CultureInfo(“en-US”)).ToString(“HH:mm:ss”)