0

I am retrieving information from my database and storing it in a reader. The contents of the reader are then used to bind a repeater.

Everything works fine. The only thing that is bugging me is that the date is displayed as 2012-01-01 00:00:00. I want the last part (that is, 00:00:00) to be removed.

How can this be done please? Thanks.

3 Answers 3

1

I think what you are trying to do is use the following:

   <asp:TemplateColumn>
   <ItemTemplate>
   <%#
   DataBinder.Eval(Container.DataItem,"database_field _name","{0:dd.MM.yyyy}")%>
   </ItemTemplate>
   </asp:TemplateColumn>

Code from this forum post. However, change the dd.MM.yyyy to T as per this page

Sign up to request clarification or add additional context in comments.

1 Comment

No problems. Happy to help! :-)
1

Sounds like you may want:

foo.ToString("yyyy-MM-dd");

although it would be better to use the "short date" standard format:

foo.ToString("d");

... which would use the appropriate format for the thread's current culture. If you are going to use a custom format string, you may well want to explicitly state the culture you want to use (potentially the invariant one); if you don't know what culture you'll be using, you don't really know whether that format is suitable for the culture.

Comments

0

Something like this:

dr.GetDateTime[3].ToString("dd/MM/yyyy");

2 Comments

Misread the question... Thank you. On a side note, just got a fresh cup of coffee...
Wait you misread question then changed it to suit your answer?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.