date formatting

  • Thread starter Thread starter cody
  • Start date Start date
Single string or binding a DataSet to a control?

For a single string, one idea is putting the string into a DateTime object
and extracting the month. A bit weighty to simply pull a month, but it can be
extremely useful if you ever need any other parts of the data.

If you are binding multiple pieces of data, you can use the String.Format()
static method to format strings however you desire. This can also be used on
a single string, so it is quite flexible.

Here is some info:
http://idunno.org/displayBlog.aspx/2004071401


---

Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

***************************
Think Outside the Box!
***************************
 
System.DateTime has a very handy override of ToString() allowing you to show
whatever you want.

System.DateTime mydate = new System.DateTime.Today.

Response.Write(mydate.ToString("MMMM d yyyy")); // December 20, 2004
Response.Write(mydate.ToString("MMMM")); // December

etc. check it out on MSDN, you'll find more examples there.
 
Back
Top