yyyy-mm-dd

R

RCS

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
 
P

Peter van der Goes

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top