#Eval Short Date

Mark Fenech picture Mark Fenech · Jan 12, 2013 · Viewed 70.5k times · Source

I am trying to add date From and date To to my products these values are store in my database as date. These are stored in this format 2013-01-15. The format is not a problem but when I display them on my application the time appears (1/15/2013 12:00:00 AM) how can I remove the time please. Below you can find the method Im databound the data.

<asp:Label ID="Label4" runat="server" Text='<% # Eval("soDateTo") %>' Font-Bold="False" Font-Size="Small"></asp:Label>

Answer

Daniel Park picture Daniel Park · Jan 12, 2013

Try String Formatting within the Eval statement: See ASP Forums

There are several ways to format the date.

<asp:label id="DateAddedLabel" runat="server" text='<%#
Eval("DateAdded", "{0:d}") %>'></asp:label>