When trying to match date formatting on the classic and RDLC versions of a report, you might run into an issue of mismatched date formatting. This can be corrected by forcing the same date format on Classic and RDLC reports. But what do you do if you want to maintain the user's setup? Consider the following date format settings on a user's PC:

NAV classic client uses regional settings for date formatting and the date is typically formatted by these settings (picture below), using the short date format.

In contrast, when using the RTC client, the RDLC report's date will be formatted by an internally chosen date format setting, and the date will be displayed differently (picture below). The RDLC report does not pick up the regional settings correctly.

To solve this problem, 1ClickFactory developers made a simple solution. First, a small piece of code needs to be added as a global function in the RDLC report code (navigation: on top menu select: Report -> on dropdown menu select: Report properties -> on displayed Report properties window choose tab: Code; picture below).

The function to correct the formatting that gets chosen for use in RDLC report is as follows:

Public Function SetLanguage( Language As String)
System.Threading.Thread.CurrentThread.CurrentCulture = New
System.Globalization.CultureInfo(Language)
End Function

The function has one parameter "Language", which is used to set the language (or, to be exactly precise - "culture code") for the report execution. After setting this, the RDLC report will correctly apply the user's regional settings for formatting. To complete the solution, a textbox control must be added on the RDLC report layout with a call to this function. The textbox must be displayed on the report layout according to these rules:

  • On Header section, if report Body section doesn't contain a list for the whole section;
  • On Body section, if report has a list for whole body section.

The textbox must have this value for the expression: 

"=Code.SetLanguage(User!Language.ToString())". 

User!Language is a built-in global report variable.
After adding this, saving and running the solution, the RDLC report will show the date according to the user's regional settings.

Good luck using it!

Author of the post: our former NAV Developer  Karolis Vansevicius