Format Date from DB

  • Thread starter Thread starter Wayne Wengert
  • Start date Start date
W

Wayne Wengert

I have an aspx page in which I retrieve data from an SQL Server. At one
point I am retrieving a smalldatetime field and I want to display only
"mm/dd/yy" but the default seems to be to add the time. The code to retrieve
that date field is: <%#Container.DataItem("LastUpdated")%>

I tried adding ".ToString("d")" but it doesn't recognize that as a
formatting function.

How can I format that returned value as mm/dd/yyyy?

Wayne
 
Hi Wayne,

You can use following code to format Date:

<%# DataBinder.Eval(Container.DataItem, "LastUpdated", "{0: MM/dd/yyyy}") %>

HTH

Elton Wang
(e-mail address removed)
 
Elton;

Thank you very much. Works perfectly. Where is that documented?

Wayne
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Back
Top