Date Format in RDLC report | RDLC report in NAV

How to convert a date into a specific date format in RDLC report? 

In RDLC report when we set a date field in a report it displays either full DateTime or it shows in a different style than we desire. We could solve this kind of situation in different ways. In my case date is displayed as 30 January 2019 but my client wants date look numeric like 01/30/2019. I normally take the following approach to format the date value:

Approach 1:

1. Select the field whose format we want to change then Right-click on the field in the RDLC report
2. Choose "Text box properties" from the list
3. Then choose the "Number" Option from Text Box Properties windows
4. Then choose one of the multiple "Date" options. There is also an option for the regional setting.


5. If you don't find your desired option in Date then specify a Custom formatting option by going to "Custom" Option. We can use a complex form as "dd.MM.yyyy HH:mm:ss".  Sample step is shown in the image as below. (Date Formatting in RDLC report)


Approach 2:  

If there is an expression or complex expression Approach 1 doesn't work as expected. In this condition, we need to write code. Some probable codes are as follows (Suppose "IssuingDate" is our field)
=CDate(Fields!IssuingDate.Value).ToString("MM/dd/yyyy")
=Format(Fields!IssuingDate.Value,"MM/dd/yyyy")

To write the code:
1. Select the field whose format we want to change then Right-click on the field in the RDLC report
2. Choose "Expression" from the list
3. Write the code in Expression window.
4. Close the window by clicking "OK".


Complex Case:

In the code given below, the Format function doesn't work properly so I used CDate function.
       

Earlier Code:

=Cstr(Choose(2,Split(Cstr(ReportItems!HeaderInfo.Value), Chr(177))))

Updated Code:

=CDate(Choose(2,Split(Cstr(ReportItems!HeaderInfo.Value), Chr(177)))).ToString("MM/dd/yyyy")


       
 

Post a Comment

Thank you for comment, I really appreciate your view.

–>