I am using
to convert my generic variable type to DateTime.
getVal is my variable which I am getting from an excel file.
The value is in a format of yyyy-MM-dd hh:mm:ss
For eg - 2022-03-01 16:26:53
I am not able to resolve the error. Please help.
Thanks in advance.
Could you give this a try?
DateTime.ParseExact("2022-03-01 16:26:53","yyyy-MM-dd HH:mm:ss",Nothing).ToString("HH:mm:ss")
DateTime.ParseExact("2022-03-01 16:26:53","yyyy-MM-dd HH:mm:ss",Nothing)
This just gives me a compiler error
Welcome to uipath forum
Try with this expression
Datatime.ParseExact(strinput.ToString.SubString(0,10).Trim, “yyyy-MM-dd”, System.Globalization.CultureInfo.InvariantCulture)
Output will be of DateTime
If you need in string of specific format
Stroutput = Datatime.ParseExact(strinput.ToString.SubString(0,10).Trim, “yyyy-MM-dd”, System.Globalization.CultureInfo.InvariantCulture).ToString(“dd/MM/yyyy”)
I want to suggest you one thing
You are almost right…
The only thing is timestamp
It’s in 24 hours format then hours should be in HH
But you have mention as hh in that DateTime expression
Change it to HH and give a try or
Try with the above suggestion
It should be fine
For more details on DateTime in uipath
My recent post on datatable [All About Datatable- UiPath] (
All about Datatable - UiPath) 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
(Output - string type - “dd/MM/yyyy hh:mm:ss”)
**To get only current da…
Try this expression
DateTime.ParseExact(“2022-03-01 16:26:53”,“yyyy-MM-dd HH:mm:ss”,Nothing) This actually works when I put the string on my own. But when I am getting the string from my excel file, it is not working
can you tell what I am possibly doing wrong?
We would ask you to Perform a Debug and Check the values of the Excel in the Immediate panel, or we could Check it with a
Write Line Activity.
This way we can know if there are other formats as well included in the dates.
Hi Can you share the sample Input Excel file
This actually worked, I changed hh to HH and it worked
Thanks a ton!!
Thankyou everyone who helped!! I was stuck at this since yesterday and this is my first time using UIpath community.
Glad it got resolved
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.