I am trying to convert a String into DateTime Variable, but the following Error occoured: “The DateTime represented by the string is not supported in calendar System.Globalization.GregorianCalendar”
Here is what i did: (I replaced my Stringvalue with DateTime.now.toString, because it throws the same Error)
Test (DateTime) = DateTime.ParseExact(DateTime.now.ToString,“dd/MM/yyyy
Assign: The DateTime represented by the string is not supported in calendar System.Globalization.GregorianCalendar
Anyone knows a Fix for this?
Thanks in advance!
Why are you converting a datetime (DateTime.Now) to string and then trying to convert it back? This makes no sense. DateTime.Now gives you a datetime value.
You have to import the system.globalization.CultureInfo namespaces from imports panel.
And try this
Strinput = Now.ToString("dd/MM/yyyy hh:mm:ss tt")
The above expression will give you the system date and time in the mentioned format…
If you wants to convert this time to GregorianCalendar
str_datetime = Datetime.ParseExact(Strinput.ToString,"dd/MM/yyyy hh:mm:ss tt",System.Globalization.CultureInfo.InvariantCulture).ToString("dd/MM/yyyy hh:mm:ss", New CultureInfo("da-DK"))
Try this and let me know
i think you not need to change because datetime.now give you datetime only if you are trying to convert another format pin that please
Converting from datetime to string back to datetime and back to string accomplishes nothing.
Let us summarize what we did understand so far
you tried to parse a string and got the exception from above
for a cross check you tried instead of the variable now.ToString but got also the same exception from above
when trying to parse it with:
then please note the swap from day and month info
so check the format of your string and adapt it accordingly in your statement. We would recommend to do quick prototyping during debugging within the immediate panel
[FirstAid] Datatable: Debug & Analysis invalid DateTime Strings / String to DateTime Parsing Issues - News / Tutorials - UiPath Community Forum
Hello @Skylon A small correction to your expression. Try this
Thank u everyone!
I learnd a lot from all your Tipps!
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.