yyyy-mm-dd

  • Thread starter Thread starter raisin
  • Start date Start date
string strFormattedDate = string.Format("{0:yyyy-MM-dd}",DateTime.Now);


string.Format takes [format and string literals], [params[] of variables]

And within the first format part, {0} refers to the first parameter.. so for
example:

string.Format("{0}, {1}, {0}, {2}", "Hello", "There", "You");

would result in:

Hello, There, Hello, You

Lastly, within the {0}, you can specify formatting things - like datatype,
precision and like above - the format. Do a search for string.Format to get
all the formatting rules..

HTH
 
raisin said:
is there an easy way of making a date appear in this
format:

yyyy-mm-dd

?

thank you

Check your MSDN help for an article "Custom DateTime Format Strings".
There is a C# example at the end of the article.
 
Back
Top