Formatting datetime field in gridview

16,155

Solution 1

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.

Solution 2

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>
Share:
16,155
user710502
Author by

user710502

Updated on June 27, 2022

Comments

  • user710502
    user710502 almost 2 years

    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" />