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)
2 Likes

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

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

Hello Arjun,
In this video I do a lot of stuff with String and DateTime:

0:35 Examples for Substring functions
4:10 IndexOf and LastIndexOf
5:00 SubString working together IndexOf and LastIndexOf
6:45 Split string by character
8:50 Split string by string
12:00 Lower Case and Upper Case
12:45 Trim
15:05 Compare strings in multiple ways
19:05 Resume of all the String function part
20:05 DateTime to string in multiple ways
23:00 AddDays get DayofWeek
25:40 Convert from String to DateTime
26:20 Compare DateTime

Thanks,
Cristian Negulescu