Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1520
  • Last Modified:

Format Datetime without seconds on GridView

One of my Gridview columns contains a datetime value that I would like formatted without seconds.  For example, a meeting is currently being displayed as 11/2/2006 6:30:00 PM.  I would like to have it displayed as /2/2006 6:30 PM.

After some research, I thought I had the answer by using DataFormatString as follows:

<
asp:BoundField DataField="Date" HeaderText="Date" DataFormatString="{0:MM/dd/yyyy HH:mm}" />

But I am still getting the seconds displayed.  How can I eliminate the seconds in the Date column of my Gridview?  Thanks for any help provided.
0
GravitaZ24
Asked:
GravitaZ24
  • 3
  • 3
1 Solution
 
nenwmnCommented:
The DataFormatString {0:MM/dd/yyyy} should work the example you show still has the hours an miniutes.
Regards, Neil
0
 
nenwmnCommented:
Restrict the length of the format string.
0
 
GravitaZ24Author Commented:
how exactly would I do that, and to respond your first answer, the only thing I'm looking to get rid of is the seconds.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
nenwmnCommented:
{0:MM/dd/yyyy HH:mm} works when tested on a bound datasource, do you get the same result using an item template label control. <asp:label id="datelabel" Text='<%# Bind("Date", "{0:MM/dd/yyyy HH:mm}") %>'</asp:label>.
Regards, Neil
 
0
 
GravitaZ24Author Commented:
oh ya, thank you! that worked well, is there a way to still have the AM/PM in it?
0
 
GravitaZ24Author Commented:
NM, thanks for all the help, i found this really helpful site for anyone else who has this question
http://authors.aspalliance.com/aspxtreme/sys/demos/datetimeformats.aspx
0

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now