Assign: String was not recognized as a valid DateTime

hello sir /madam
i pick date in this format “28-Dec-2019” from excel and convert it another format but it gives me e
Assign: String was not recognized as a valid DateTime.
how can i solve this issue
regards arjun

Hi @arjun_27,

Are you using DateTime.ParseExact ?

Try:

DateTime.ParseExact(this.Text, "dd-MMM-yyyy", CultureInfo.InvariantCulture)

Or:

DateTime.ParseExact(this.Text, "dd-MMM-yyyy", null)
1 Like

What Rene said but it should be "dd-MMM-yyyy"

https://docs.microsoft.com/en-us/dotnet/standard/base-types/custom-date-and-time-format-strings?view=netframework-4.8

1 Like

be careful with your statement there, if your excel has that column formatted as date, then you should not care about any format, just use the data as DateTime…

null does not exist in vb.net it should be Nothing

i have scrape the data from pdf

humm… in your post, you say excel…

sorry but i scrape date from pdf and write in excel
regards arjun