Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Formatting datetime field in gridview

I have a field in a gridvie that displays the date in the following format

1/2/2012 3:45:13 AM

How can I format it so that it does ot show the seconds?

Thank you

   <telerik:GridBoundColumn 
    DataField="AdmissionDate" 
    HeaderText="Date" 
    SortExpression="AdmissionDate"
              HtmlEncode="False" />
like image 809
user710502 Avatar asked Feb 09 '26 22:02

user710502


2 Answers

Try this(short date and short time):

DataFormatString="{0:g}"

Although this is for BoundFields in an ASP.NET GridView, i assume(i have no experiences with Telerik controls) that it works also on a Telerik GridBoundColumn, because it also has this property.

  • http://msdn.microsoft.com/en-us/library/system.globalization.datetimeformatinfo.aspx
  • http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.boundfield.dataformatstring.aspx
like image 147
Tim Schmelter Avatar answered Feb 12 '26 15:02

Tim Schmelter


Something like this:

<Columns>
    <telerik:GridBoundColumn
        DataField="AdmissionDate"
        DataType="System.DateTime"
        HeaderText="AdmissionDate"
        SortExpression="OrderDate"
        DataFormatString="{0:MM/dd/yy hh:mm}"
        UniqueName="AdmissionDate">
    </telerik:GridBoundColumn>
like image 43
Stef Heyenrath Avatar answered Feb 12 '26 14:02

Stef Heyenrath



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!