RDLC-Report and CultureInfo on Datetime-Format
-
10-07-2019 - |
Question
I'm using the Report System from Visual Studio (not Crystal Reports but RDLC). It works fine, but my problem is, that when setting the "Format code" on a Date-Field to "D" it formats it to an English Date (Wednesday, June 24, 2009) instead using my CultueInfo (German) and I can't find out how to pass a Culture-Info to the Report or the Date-Format.
Solution
You can set the language property for the report too: http://i31.tinypic.com/1z3zbjd.jpg
OTHER TIPS
If you can't set the culture on the report, try creating a property on your class that does the conversion and returns it as a string.
public class YourClass
{
public DateTime Date{ get; set; }
public string FormattedDate
{
get { return Date.ToString("D", new System.Globalization.CultureInfo("de-DE")); }
}
}
From your report you can access it as "=Fields!FormattedDate.Value".
I know this question was answered a while ago but I needed to get a report to use the current UI culture (rather than a hard coded culture) when formatting dates in an RDLC report.
For the current UI culture you need to set the Report's Language property to =User!Language
. Hope this helps anyone who comes up against the same problem.
=Format(Fields!FormattedDate.Value).("dd/MM/yyyy")