Thursday, September 7

SRSS - How To Append 'st', 'nd', 'rd' or 'th' To Day Numbers in Dates

Microsoft Dynamics AX ERP systems in it is a large and completed ERP Solution of all Time, but different user have different sets of requirement to achieve his/her business goal. A common example among all is to append Day number with  'st', 'nd', 'rd' or 'th'. Which is not possible in SSRS Report, because there are a lots of format available for date but you will not found any solution regarding this problem.

The available format in SSRS Reports are as following:
Formatting Date and Time in SQL Server Reporting Services (SSRS) is a very common need. And in some cases customers look for a very specific format, so it is important to understand the basic components of date and time formats.
SSRS offers many in-built Date and Time formats. Below are some of the in-built Date formats available in SSRS:
For appending all the above suffix you need to follow following steps:
1. Open any Report in Visual Studio and insert a textbox contain Data Field of Date Type,

2. Right Click on Textbox, Go To Text Box Properties

3. Click on Number tab, click on custom format option then click on fx button in black.

4. A form will open, copy the below text and paste there to need to change following text with your database date field.

Fields!FieldName.Value, "Dataset"

1. Replace FieldName with your Date Field
2. Replace Dataset       with your Dateset Name


="d" + switch(int(Day((Fields!FieldName.Value, "Dataset"))) mod 10=1,"'st'",int(Day((Fields!FieldName.Value, "Dataset"))) mod 10 = 2,"'nd'",int(Day((Fields!FieldName.Value, "Dataset"))) mod 10 = 3,"'rd'",true,"'th'") + " MMMM, yyyy"


5. Press ok, Again ok. Deploy your report and check it on AX. Enjoy!!

No comments:

Post a Comment

Popular Posts