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
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
Response.Write(DateTime.Parse(dr("CreateDate").ToString()).ToString("MM/dd/yyyy"))
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.
Easy:
((DateTime)dr["CreateDate"]).ToString("MM/dd/yyyy")
// I would also check that it isn't dbnull before doing it though
if (! DBNull.Value.Equals(dr["CreateDate"])) // blah blah
string.Format( "{0:MM/dd/yy}", dr("CreateDate") )
Edit: If dr("CreateDate") is DBNull, this returns "".