I have a date like this:- 20091023 i have to convert it to a suitable format so that i can insert it into the database.For this firstly i have to convert it to 2009/10/23.How can i do this?
DateTime
.ParseExact("20091023", "yyyyMMdd", CultureInfo.InvariantCulture)
.ToString("yyyy/MM/dd")
If you want to insert the date into a database, then don't convert to a different string: convert it to a DateTime value (using ParseExact or TryParseExact). Then use a parameter (of a date type) in the query to use this value in the database.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With