Click here to Skip to main content
15,906,467 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi everyone!
I'm creating a news page for my site and I extract news from the DB table "News"
My table structure:
NewsItemID    uniqueidentifier NOT NULL PRIMARY KEY DEFAULT NEWID( ),
NewsItemTitle nvarchar(500) NOT NULL,
NewsItemContent ntext NOT NULL,
NewsItemDate  datetime NOT NULL


I create such DataList .aspx page..
<asp:DataList ID = "listNews" runat = "server" DataSourceID = "srcNews" EnableViewState = "false">
        <HeaderTemplate>
         <span style="color: Orange; font-size: x-large; ">Latest news </span>
        </HeaderTemplate>
         <itemtemplate>
          <div style="border: 1px solid white; removed: relative; padding: 5px 10px 0px 10px; margin-removed 15px;" önmouseover="this.className = 'hot_ITEM';" önmouseout="this.className =''">
            <span style="color: Orange; font-size: larger;"><bold><%# this.Eval("NewsItemTitle") %></bold></span>
            <br />
            <span style="color: White;"><%# this.Eval("NewsItemContent") %> </span>
            <br />
            <span style="color: White; removed: absolute; removed 0; removed auto; margin-removed 5px; margin-removed auto; removed 0;"><%# this.Eval("DT") %></span>
          </div>
         </itemtemplate>


But when iut comes to displaying dates it shows me in such format: 09/12/1977 12:33
How to format datetime strings so it would show me only DATES (not time) and localized please???
Posted
Updated 11-Apr-11 7:25am
v5

1 solution

Try something like -
<%# Eval("DT", "{0: d}") %>
 
Share this answer
 
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900