Format Date from DB

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
 
G

Guest

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)
 

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

Date format 3
date format question 2
Date format in Datagrid 2
Date format 4
Date Format Incorrect 2
Format date 2
Date format strings not being applied? 3
Getting client side regional settings date format 3

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,825
Latest member
VernonQuy6

Latest Threads

Top