Date coming out of a database, need to format as "mm/dd/yy"
For Each dr as DataRow in ds.Tables(0).Rows
Response.Write(dr("CreateDate"))
Next
string.Format( "{0:MM/dd/yy}", dr("CreateDate") )
Edit: If dr("CreateDate") is DBNull, this returns "".
Convert.ToDateTime(dr("CreateDate")).ToShortDate()
See the MSDN docs for other functions available from the DateTime datatype, including custom formats available through the 'ToString' function.
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