overriding date format settings dynamically from .mrt files
-
- Posts: 19
- Joined: Tue Feb 16, 2016 10:16 am
overriding date format settings dynamically from .mrt files
Hi,
I have one query regarding over writing the date time format dynamically, if we have already set something in the .mrt files as follows.
I want to set the date format as dd/MM/YYYY dynamically.
Below is the date format setting from .mrt file which we want to override dynamically:
<Text>Ending Date: {rpt.EndDate.ToString("MM/dd/yyyy")}</Text>
OR
<value>Formulas,fxOrderDate,fxOrderDate,System.String,GetCompanyAddress.dateFormat_x0020__x003D__x003D__x0020__x0022_Italian_x0022__x000D__x000A__x003F_rptPoForm.PODATE.ToString_x0028__x0022_dd-MMMM-yyyy_x0022__x0029__x000D__x000A_:rptPoForm.PODATE.ToString_x0028__x0022_MM_x002F_dd_x002F_yyyy_x0022__x0029_,True,True</value>
So, in short please let me know if we can over write the above settings dynamically by the date format we want, without changing .mrt file. Might be like doing some changes at back end etc.,
Thanks,
I have one query regarding over writing the date time format dynamically, if we have already set something in the .mrt files as follows.
I want to set the date format as dd/MM/YYYY dynamically.
Below is the date format setting from .mrt file which we want to override dynamically:
<Text>Ending Date: {rpt.EndDate.ToString("MM/dd/yyyy")}</Text>
OR
<value>Formulas,fxOrderDate,fxOrderDate,System.String,GetCompanyAddress.dateFormat_x0020__x003D__x003D__x0020__x0022_Italian_x0022__x000D__x000A__x003F_rptPoForm.PODATE.ToString_x0028__x0022_dd-MMMM-yyyy_x0022__x0029__x000D__x000A_:rptPoForm.PODATE.ToString_x0028__x0022_MM_x002F_dd_x002F_yyyy_x0022__x0029_,True,True</value>
So, in short please let me know if we can over write the above settings dynamically by the date format we want, without changing .mrt file. Might be like doing some changes at back end etc.,
Thanks,
Re: overriding date format settings dynamically from .mrt fi
Hello,
Please try to use the Culture property for the report. You can set the necessary culture before render report.
Thank you.
Please try to use the Culture property for the report. You can set the necessary culture before render report.
Thank you.
-
- Posts: 19
- Joined: Tue Feb 16, 2016 10:16 am
Re: overriding date format settings dynamically from .mrt fi
this.GlobalizationManager.Culture = CultureInfo.CurrentCulture;
Is this the correct way? I'm trying it and will share my results. Please let me know if I need to do anything else other than what I'm doing.
Is this the correct way? I'm trying it and will share my results. Please let me know if I need to do anything else other than what I'm doing.
Re: overriding date format settings dynamically from .mrt fi
Hello.
Here is the code that set the Culture property of the report:
Thank you.
Here is the code that set the Culture property of the report:
Code: Select all
this.Culture = "en-US";
-
- Posts: 19
- Joined: Tue Feb 16, 2016 10:16 am
Re: overriding date format settings dynamically from .mrt fi
I tried to set the culture property as shown below, but it failed to override the date format settings from .mrt file.
Initially I tried to set below property,
this.GlobalizationManager.Culture = new CultureInfo("ms-MY");
Also followed the way you suggested,
this.Culture = "ms-MY";
this.GlobalizationManager.Culture, has properties like datetime format and I was able to see that the culture I set was reflecting correctly in Culture object (i.e., "ms-MY" with date format as dd/MM/yyyy ), but the end result was not changed and the date displayed was in MM/dd/yyyy format.
Please help me as I'm running out of time.
Initially I tried to set below property,
this.GlobalizationManager.Culture = new CultureInfo("ms-MY");
Also followed the way you suggested,
this.Culture = "ms-MY";
this.GlobalizationManager.Culture, has properties like datetime format and I was able to see that the culture I set was reflecting correctly in Culture object (i.e., "ms-MY" with date format as dd/MM/yyyy ), but the end result was not changed and the date displayed was in MM/dd/yyyy format.
Please help me as I'm running out of time.
-
- Posts: 19
- Joined: Tue Feb 16, 2016 10:16 am
Re: overriding date format settings dynamically from .mrt fi
When I change the below line in .mrt file,
<Text>Ending Date: {rpt.EndDate.ToString("MM/dd/yyyy")}</Text>
To
<Text>Ending Date: {rpt.EndDate}</Text>
The culture setting gets applied and the EndDate field gets displayed in the desired format. I think as we have set the field as to string, the culture property doesn't change it.
As we have lot of reports and changing the reports one by one is not feasible, please suggest the best way to override the date format dynamically without having changes in the .mrt files.
<Text>Ending Date: {rpt.EndDate.ToString("MM/dd/yyyy")}</Text>
To
<Text>Ending Date: {rpt.EndDate}</Text>
The culture setting gets applied and the EndDate field gets displayed in the desired format. I think as we have set the field as to string, the culture property doesn't change it.
As we have lot of reports and changing the reports one by one is not feasible, please suggest the best way to override the date format dynamically without having changes in the .mrt files.
Re: overriding date format settings dynamically from .mrt fi
Hello.
Here are results of rendering next expression:
The Culture property works as expected.
Could you specify which version of our product you use?
Thank you.
Here are results of rendering next expression:
Code: Select all
Today: {Today}
{this.Culture}
Could you specify which version of our product you use?
Thank you.
-
- Posts: 19
- Joined: Tue Feb 16, 2016 10:16 am
Re: overriding date format settings dynamically from .mrt fi
Hello,
Yes, you are correct. But does it works even if the date field is set as a string expression in the .mrt file as I have mentioned above?
I'm using Stimulsoft's Reports.Web Reporting Tool for ASP.NET MVC.
Thanks,
Yes, you are correct. But does it works even if the date field is set as a string expression in the .mrt file as I have mentioned above?
I'm using Stimulsoft's Reports.Web Reporting Tool for ASP.NET MVC.
Thanks,
Re: overriding date format settings dynamically from .mrt fi
Hello.
If the DateTime is passed to the report as string in should be in right format.
It should correspond the Culture or be in ISO 8601 format.
If you change Culture, but the date is in format from different Culture it will not parsed right.
Please try to use the ISO 8601 format.
Thank you.
If the DateTime is passed to the report as string in should be in right format.
It should correspond the Culture or be in ISO 8601 format.
If you change Culture, but the date is in format from different Culture it will not parsed right.
Please try to use the ISO 8601 format.
Thank you.
Re: overriding date format settings dynamically from .mrt fi
Hello.
Anyway if you set the custom format with ToString method you should change it.
Maybe you could use next format specifier:
<Text>Ending Date: {rpt.EndDate.ToString("d")}</Text>
or you could specify date format in GlobalizationManager.
Thank you.
Anyway if you set the custom format with ToString method you should change it.
Maybe you could use next format specifier:
<Text>Ending Date: {rpt.EndDate.ToString("d")}</Text>
or you could specify date format in GlobalizationManager.
Thank you.