Hi,
I have extracted rows of data from Excel in the string of (MM/dd/yyyy)
How do i transform this string variable into a date variable? I need this transformation in order to test if a date is “too old” in an if-function.
Thanks in advice.
Hi,
I have extracted rows of data from Excel in the string of (MM/dd/yyyy)
How do i transform this string variable into a date variable? I need this transformation in order to test if a date is “too old” in an if-function.
Thanks in advice.
@Karsten_Bertelsen Try this:
DateTime.ParseExact(yourDateString,“MM/dd/yyyy”, System.Globalization.CultureInfo.InvariantCulture)
@Karsten_Bertelsen
DateTime.ParseExact(YourDateString, “MM/dd/yyyy”, CultureInfo.InvariantCulture)
ensure:
Hi @supermanPunch & @ppr
Thanks for your suggestions!
I am getting the following error when trying to implement the suggestion:
row(3).toString is needed
@ppr that solved the error, but not im getting this format exception
The excel file contains the format as “M/dd/yyyy” but i cant seem to figure out what im missing. -I corrected the suggestion to:
DateTime.ParseExact(yourDateString,“M/dd/yyyy”, System.Globalization.CultureInfo.InvariantCulture)
was your input, right? In case of you have to deal with different formats let us know, we can modify the statement.
For analysing debug / breakpoint and have a look into the datatable
If you got that error, then it suggests that your excel already have the dates as DateTime format and you dont need all this… Actually sorry, not the case, but when you do the ToString, if it was date format, then you are there changing its format… So if it really is string, do like this instead:
DateTime.ParseExact(Ctype(row(3),String),"MM/dd/yyyy", Nothing)