Hi,
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.
Thanks.
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
satish_kumar:
“5:35:50 AM”
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
Gokul001
(Gokul Balaji)
March 14, 2022, 11:17am
4
HI @satish_kumar
Try this below expression
CDate("4:35:50 PM").ToString("HH:mm:ss")
Regards
Gokul
2 Likes
Hi
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
Hi All,
My recent post on datatable [All About Datatable- UiPath] (https://forum.uipath.com/t/all-about-datatable-uipath/386445 ) was received well in forum with great feedbacks and many suggested to provide some tutorial on topics which are discussed often in our forum
In regards to that I would like to share the commonly used expression for DATETIME conversion
Let’s get started one by one
1. Get Current Date in string format
Datetime.Now.ToString()
(Output - string type - “dd/MM/yyyy hh:mm…
Cheers @satish_kumar
1 Like
postwick
(Paul Ostwick)
March 14, 2022, 1:37pm
6
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”)