I am trying to compare two dates. One is the date extracted from mail through Outlook which is of the type string and the other one is the System’s date and the type is DateTime. In order to compare these two I am using Compare Date feature which expects variable in Date form. How do I go about. Please suggest some idea.
Thanks @aksh1yadav for the help. I tried this in my workflow but I am getting an error. I have attached the screenshot of that. Also if you could explain about CultureInfo.InvariantCulture, it would be of great help.
You are getting this problem because you have not imported the namespace “System.Globalization”.
once you will import it, you will not get that error.
Not all cultures use the same format for dates and decimal / currency values.
This will matter for you when you are converting input values (read) that are stored as strings to DateTime, float, double or decimal. It will also matter if you try to format the aforementioned data types to strings (write) for display or storage.
In the Windows operating system the user may even customize how numbers and date/times are formatted and may also choose another culture than the culture of his operating system. The formatting used is the choice of the user which is how it should be.
So when you format a value to be displayed to the user using for instance ToString or String.Format or parsed from a string using DateTime.Parse or Decimal.Parse the default is to use the CultureInfo.CurrentCulture. This allows the user to control the formatting.
However, a lot of string formatting and parsing is actually not strings exchanged between the application and the user but between the application and some data format (e.g. an XML or CSV file). In that case you don’t want to use CultureInfo.CurrentCulture because if formatting and parsing is done with different cultures it can break. In that case you want to use CultureInfo.InvariantCulture (which is based on the en-US culture). This ensures that the values can roundtrip without problems
Are you sure about this?
I’m pretty certain that for calls made within UiPath the default culture is invariant, unless you specifically provide a different one.
Sample output when running on pl-PL user settings and en-US interface:
Same will happen with Decimal.Parse etc.
Unless by default you ment good practice, in which case I agree (in most cases - monitoring systems are IMHO better left at UTC or one specific timezone).