?
Solved

Format column with date value

Posted on 2006-05-23
8
Medium Priority
?
214 Views
Last Modified: 2012-06-27
If I open the Columns collection for a DataGrid, and select a column that displays a date value, how do I specify a "Data formatting expression" that will show mm/dd/yyyy   instead of mm/dd/yyyy hh:mm:ss AM/PM

I am not interested in the Time, just the date.

Also....what is the Data Formatting Expression, exactly?  Where can I find guidelines on the proper syntax to use?
0
Comment
Question by:Tom Knowlton
  • 4
  • 4
8 Comments
 
LVL 9

Accepted Solution

by:
HappyFunBall earned 2000 total points
ID: 16746091
Use the formatting string for short date: {0:d}  

Or you can use {0:MM/dd/yyyy}

Here's more info:  http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconformattingtypes.asp
0
 
LVL 5

Author Comment

by:Tom Knowlton
ID: 16746168
How was I supposed to know to start with  {0:   and end with  }    ?????

Just curious how somebody would know this otherwise.
0
 
LVL 9

Expert Comment

by:HappyFunBall
ID: 16746213
I asked myself the same question at first.  It is too far buried in the documentation, in my opinion.
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 5

Author Comment

by:Tom Knowlton
ID: 16746248
does the link you gave me talk about needing the   "{0:  }"  ???
0
 
LVL 9

Expert Comment

by:HappyFunBall
ID: 16746308
0
 
LVL 5

Author Comment

by:Tom Knowlton
ID: 16746369
Still not clear on what the

0:


The link you gave just now does not talk about it, does it?

Am I just not reading carefully enough?
0
 
LVL 9

Expert Comment

by:HappyFunBall
ID: 16747904
In the bound column example, I'm not really sure what the 0: means, except that it represents the first item to be formatted.  

That's clearer when you look at the String.Format or String.AppendFormat functions.  For example, this code:

Dim myString as String = String.Format("Which day of the week is {0:MM/dd/yyyy}?  It is {1:dddd}", Date.Now, Date.Now)
Response.Write(myString)

Yields this result:  Which day of the week is 5/23/2006?  It is Tuesday.

Have a look at the String.Format function examples on this page:  http://msdn2.microsoft.com/en-US/library/txafckwd.aspx
0
 
LVL 5

Author Comment

by:Tom Knowlton
ID: 16752190
This makes more sense now.

Thanks!
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Suggested Courses

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question