You simply format the date with a custom format string:
string formatted = theDate.ToString("yyyyMMdd");
Note that a date does not have a format at all when it is stored as a date-time in the database. This is just a point in time; it does not have a specific textual representation until it is specially created from the date.
source share