How to Change Date Format in .Net Rdlc Report

Change date format in Parameter (RDLC Report)

You can try this,

=Format(CDate(Parameters!DateTimeFrom.Value),"MM-dd-yyyy")

OR if you want to show time also- MM-dd-yyyy hh:mm:ss , then you should try below,

=Format(CDate(Parameters!DateTimeFrom.Value),"MM-dd-yyyy hh:mm:ss")

How to make RDLC use date format from control panel

Ok, this is a little bit evil, but I don't see any alternative until Microsoft fix their bug.

  1. Ensure that reports do not set the Language to =User!Language (and don't set the Language at all unless you want to force particular non-defaults for that particular report).
  2. Add the Lib.Harmony NuGet package to your project. (The code below assumes you're using 1.2; you might need to tweak it slightly for a later version.)
  3. Add the following class:
    public static class ReportViewerBugFix
{
public static void Patch()
{
HarmonyInstance.Create("fix.broken.microsoft.reportviewer").Patch(
AccessTools.Method("Microsoft.ReportingServices.Diagnostics.Localization,Microsoft.ReportViewer.Common:get_DefaultReportServerSpecificCulture"),
prefix: new HarmonyMethod(AccessTools.Method(typeof(ReportViewerBugFix), nameof(PatchDefaultReportServerSpecificCulture))));
}

private static bool PatchDefaultReportServerSpecificCulture(ref CultureInfo __result)
{
__result = CultureInfo.CurrentCulture;
return false;
}
}

  1. Call ReportViewerBugFix.Patch() early in your app startup.

(For extra paranoia, you could capture CultureInfo.CurrentCulture at the time that Patch is called and return that value instead of re-querying it later. However the above worked as-is for all the cases that I tried.)

This changes the return value of DefaultReportServerSpecificCulture to be the same as ClientPrimaryCulture, because that's easier to do in an external patch than to make EvaluateReportLanguage call the right thing instead (which would probably be the better solution, with access to the code). But it's ok because there's absolutely no reason you'd ever want to use the Windows UI Language in the first place.

How I can format date in report to appear exactly as I want - RDLC

That expression do the trick

=CDate(Fields!Fecha.Value).ToString("yyyy/M/d")

How to Display, Local System Date Format in RDLC Field

I guess you want your date time in this format < Day-Month-Year >
Well it's simple

        DateTime a = new DateTime();
string localDate = a.Day + "-" + a.Month + "-" +a.Year;

And if you just want to edit current Date you got:

        string input = "25/5/2017"; //Get your input how you want
string[] a = input.Split('/');
string output = a[0] + "-" + a[1] + "-" + a[2];


Related Topics



Leave a reply



Submit