DataBinder.Eval format date with "th"

Posted on 2012-08-29
Last Modified: 2012-08-29

I am formatting a date as follows:

<%#DataBinder.Eval(Container.DataItem, "news_date", "{0:dd MMMMMM yyyy}")%>

This formats the date as: 29 August 2012

Is there a way format the date as: 29th August 2012


Question by:rpm
    LVL 83

    Accepted Solution

    What if date is 1 August, or 2 August, or 3 August? It would need to be intelligent so you probably want to write a method which returns you formatted date

    <%#FormatDate(DataBinder.Eval(Container.DataItem, "news_date", "{0:dd MMMMMM yyyy}"))%>

    Public Function FormatDate(TheDate As Date) As string
         'Logic here
    End Function
    LVL 1

    Author Comment

    Obvious when you think about it!

    Thanks that did the trick nicely.

    Featured Post

    Better Security Awareness With Threat Intelligence

    See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

    Join & Write a Comment

    Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
    IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
    To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…
    Internet Business Fax to Email Made Easy - With eFax Corporate (, you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

    729 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now