The date format does not work

2 posts, 0 answers
  1. Patrik
    Patrik avatar
    7 posts
    Member since:
    May 2009

    Posted 22 Sep 2016 Link to this post

    I want to format the date in a "dd.MM.yyyy" I've already tried several options but none that work.

    The date is stored in the table as Datetime2.


    <telerik:RadListView runat="server" ID="rlvEmployes" ClientDataSourceID="rcdsEmployes">
                    <div class="RadListView RadListView_Default">
                        <ul class="employes-list" id="itemPlaceholder" runat="server" style="list-style-type:none;">
                                <div class="itemTemplate" data-employe-id="#= ZamestnanecID #">
                                    <div class="header">#= Prijmeni # #= Jmeno #</div>
                                    <div class="content">
                                                    <span class="label">Aktivní:</span>
                                                    <input type="checkbox" #= Aktivny ? 'checked="checked"' : '' # />
                                                    <span class="label">Datum narození:</span>
                                                    <span class="info">#= format(DatumNarozeni, "{0:dd/MM/yyyy}") #</span>
                                                    <span class="label">Číslo OP:</span>
                                                    <span class="info">#= CisloOP #</span>
                                <div class="editTemplate" style="display:none;">
                                    <telerik:RadTextBox runat="server" Text='#= ZamestnanecID #'></telerik:RadTextBox>


    Where I make mistakes?

  2. Viktor Tachev
    Viktor Tachev avatar
    2194 posts

    Posted 27 Sep 2016 Link to this post

    Hi Patrik,

    If the date field is a DateTime object it is expected to be stored in the data source as such. Note that the specified format is used only for displaying the date in a format that is easier for the user to read it.

    This approach provides great flexibility when working with dates. Especially when implementing manual logic or calculations. Moreover, when the date is stored as DateTime in the data source there is no need to parse the value entered by the user to determine what is the entered date.

    Viktor Tachev
    Telerik by Progress
    Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
Back to Top