dateCurrentPerson=DateTime.Parse(birthDates(item))
in this line “Assign: String was not recognized as a valid DateTime.” I am getting such an error. Could you help???
Try this:
DateTime.ParseExact(“your datetime”, “datetime format you’re trying to parse”, CultureInfo.InvariantCulture)
For example
DateTime.ParseExact(“11/08/2022”, “dd/MM/yyyy”, CultureInfo.InvariantCulture)
Remember:
dd refers to days
MM to months
yyyy to year
hh to hour
mm to minutes
ss to seconds
Hi @Emre_Emek,
What exactly do you want to output and what are your variables? Can you give details ?
Regards,
MY
DateTime.Parse only works if the string date is formatted the same as whatever your system default is.
Since it’s failing, we can assume the format of your string date is not the same as your system default, so you need to use ParseExact as mentioned above, and tell it the exact format of your string date.
Try this: dateCurrentPerson=DateTime.ParseExact(birthDates(item),“dd/MM/yyyy”, CultureInfo.InvariantCulture)
Compiler error(s) encountered processing expression “DateTime.ParseExact(birthDates(item),“dd/MM/yyyy”, CultureInfo.InvariantCulture)”.
Could you please post the complete compiler error?
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.