Search code examples
crystal-reportsdate-formatting

How can I format '07/03/2018' to 'March 7th 2018' in Crystal Reports


I need to show the date format as March 7th 2018 in crystal reports. I tried this using Format editor in crystal report It gives as March 07 2018 but not as I wanted. How to do this formatting?


Solution

  • As already mentioned in comments, there's no builtin function in Crystal Reports to format the day as 1st, 2nd, 3rd, 4th...

    With the following formula you will get the desired result:

    Select Day({@myDate})
        Case 1, 21, 31:
            ToText({@myDate}, "MMMM d'st' yyyy")
        Case 2, 22:
            ToText({@myDate}, "MMMM d'nd' yyyy")
        Case 3, 23:
            ToText({@myDate}, "MMMM d'rd' yyyy")
        Default:
            ToText({@myDate}, "MMMM d'th' yyyy")
    

    Note: The month-name will be displayed depending on the locale-settings of your system.