how to convert date type?

Stimulsoft Reports.NET discussion
Post Reply
behrooz1364
Posts: 4
Joined: Thu Sep 01, 2011 10:50 am

how to convert date type?

Post by behrooz1364 »

Hi
i want my date textboxes show the date as shamsi(persian or farsi) date how can i change that?
no matter in code or in report file.
thank you in advance.
HighAley
Posts: 8430
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

how to convert date type?

Post by HighAley »

Hello.
behrooz1364 wrote:i want my date textboxes show the date as shamsi(persian or farsi) date how can i change that?
no matter in code or in report file.
thank you in advance.
You can write your function on the Code tab in the begin of report, for example:

Code: Select all

namespace Reports
{
    public class Report : Stimulsoft.Report.StiReport
    {
		
		public string DateToHijri(object date)
		{
			System.Globalization.HijriCalendar hijri = new System.Globalization.HijriCalendar();

			DateTime greg = (DateTime)date;
			int year = hijri.GetYear(greg);
			int month = hijri.GetMonth(greg);
			int day = hijri.GetDayOfMonth(greg);

			return day.ToString() + "/" + month.ToString() + "/" + year.ToString();
		}
Thank you.
behrooz1364
Posts: 4
Joined: Thu Sep 01, 2011 10:50 am

how to convert date type?

Post by behrooz1364 »

thank you
Andrew
Posts: 4109
Joined: Fri Jun 09, 2006 3:58 am

how to convert date type?

Post by Andrew »

Hello,

Let us know if you have additional questions.

Thank you.
Mohamad Hoosein Fakhravary
Posts: 1
Joined: Mon May 28, 2012 5:48 pm
Location: iran

how to convert date type?

Post by Mohamad Hoosein Fakhravary »

Hello
How do I use the above function
:byebye:
Image
محمد حسین فخراوری
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

how to convert date type?

Post by Alex K. »

Hello,

You can use the following expression:

Code: Select all

{DateToHijri(B_Topics.Date)}
Thank you.
a.ebbini
Posts: 101
Joined: Thu Jun 05, 2014 8:10 am
Location: Jordan

Re: how to convert date type?

Post by a.ebbini »

Is there a generic solution for this issue i have a system that display in Gregorian and i want to add to a generic option to display in hijri without going to every report in the system. i have about 200 reports.
a.ebbini
Posts: 101
Joined: Thu Jun 05, 2014 8:10 am
Location: Jordan

Re: how to convert date type?

Post by a.ebbini »

Hello,
I found a solution to convert culture before render
Dim C As New Globalization.CultureInfo("ar-SA")
Dim TheCalendar As New System.Globalization.HijriCalendar
C.DateTimeFormat.Calendar = TheCalendar
Threading.Thread.CurrentThread.CurrentCulture = C

Report.Render
'Then return original culture
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

Re: how to convert date type?

Post by Alex K. »

Hello,

Ok.
Let us know if you need any additional help.

Thank you.
Post Reply