Convert string into specific datetime format

Hello together,

I have the following problem:
I want to convert a value of CurrentRow from type String to type DateTime. Using the expression Convert.ToDateTime(CurrentRow(0).ToString), the format looks like this: “07/08/2023 00:00:00” (for the date August 7th, 2023).
I want to write this DateTime value to a datatable, but without the 00:00:00 time information. So far, I have only been able to find options that convert the value back to a string to allow a split at the space. For my case the date must remain in DateTime format.

Thanks in advance and best regards

will take first part as month, so July would result

We can do without splitting:

But we recommend inspecting the data table and cross-check how the date strings are stored within the data table as described here:
:ambulance: :sos: [FirstAid] Datatable: Debug & Analysis invalid DateTime Strings / String to DateTime Parsing Issues - News / Tutorials - UiPath Community Forum

DateTime is a structure and we will not touch the internal structure

Hi @birkms

=> Assign -> strvar="07/08/2023 00:00:00"      (Datatype: System.String)

=> Assign -> datevar=CDate(strvar).ToString("dd/MM/yyyy")         (Datatype: System.String)

Note - StrVar is a String datatype Variable and DateFormat is a DateTime datatype Variable

Check the below image for better understanding.

Hope it helps!!


dateString = currentRow(0).ToString()

dateValue =DateTime.ParseExact(dateString,“dd/MM/yyyy HH:mm:ss”,System.Globalization.CultureInfo.InvariantCulture)


you may try this -
DateTime.ParseExact(CurrentRow(0).ToString,“dd/MM/yyyy HH:mm:ss”, System.Globalization.CultureInfo.InvariantCulture).ToString(“dd/MM/yyyy”)


1 Like


first of all thank you for the quick answers!
I have tested all options but still face the same problem. The date comes out in the correct format (like 07/08/2023 without the time), but the final datatype in each option is still a string and not a datetime… or am I doing somehting wrong?

Thanks in Advance!