I'm querying a datetime (dd/mm/YYYY hh:mm:ss) value from a database and inserting it in a list like this:
ord.invoiceDate = dt.Rows[i]["invoicedate"].ToString();
How can I convert this string to a custom format like dd-MM-YYYY ? I don't want the hours minutes and seconds.
Try this
ord.invoiceDate = ((DateTime)dt.Rows[i]["invoicedate"]).ToString("dd-MM-yyyy");
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