Trying to convert a string that pull from an excel file into a date to compare if it before another date input.
The string is stored into the format yyyymmdd. From research I found the DateTime.ParseExact method but I’m a little confused with the IFormatProvider parameter.
I was planning on storing the date converted into a temp variable and comparing it with a date from user input.
start a try with DateTime.ParseExact(YourDateTimeString,“yyyyMMdd”,CultureInfo.InvariantCulture)
ensure that System.Globalization is imported to the namespace (see right, close to the variable panel tabs)
About your question:
e.g Dates/numbers … are different formatted within the different Countries/Cultures. Such formatting specifics are organized in e.g. CultureInfo
About your Plan:
Yes, once parsed into a datetime variable it can be used for logical operations e.g <, =, >…
Seems that every time I try to install the System.Globalization package I get an error saying Package installation failure. The version is currently 4.3.0 and if I try to install an earlier version it forces me to update.
found it. but before I did an error was appearing where it could not recognize CultureInfo. Do not remember changing anything to the file but it appears to be working now. Thank you @ppr
Note there is a correction, partly because of my question wording you have to use MM to identify the time as months inside the string else mm identifies the time as minutes in the string