0

I'm using the following in my grid view to display two dates in a single column. How can I change this so the date format will be like dd MMM yyyy without the time?

<asp:TemplateField HeaderText="Date Range">
    <ItemTemplate>
        <%# string.Format("{0} {1}", Eval("From_Date ") ,Eval("To_Date"))%>
    </ItemTemplate>
</asp:TemplateField>
0

It should be a matter of adding :dd MMM yyyy after 0, resp 1

Like:

<asp:TemplateField HeaderText="Date Range">
    <ItemTemplate>
        <%# string.Format("{0:dd MMM yyyy} {1:dd MMM yyyy}", Eval("From_Date") ,Eval("To_Date"))%>
    </ItemTemplate>
</asp:TemplateField>
| improve this answer | |
  • Thanks Robert - that works perfectly. Any Idea how I might be able to hide the second date when it is the same as the first date? I'm posting a new question about this anyway, but maybe you know how... – Pieter Du Toit Nov 15 '13 at 7:32
  • I have given it a shot! not sure it is corret though as I can't compile it right now – Robert Lindgren Nov 15 '13 at 7:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.