Page 1 of 1

display name of the month

Posted: Fri Apr 30, 2010 9:26 pm
by reynard
is there any function in report designer to convert the month into name?
ex.

3/3/2010.. into just march

or maybe i use query in sql to get the month only and then some function can convert 3 to march..

thanks..

display name of the month

Posted: Sat May 01, 2010 12:24 am
by Jan
Hello,

For example:

Code: Select all

{Today.ToString("MMMM")}
Thank you.

display name of the month

Posted: Sat May 01, 2010 1:37 am
by reynard
how about if i want to make something like this:

1=January
2=February
.
.
.
12=December.

is it possible?

display name of the month

Posted: Mon May 03, 2010 2:35 am
by Ivan
Hello,

You can use following expression:

Code: Select all

{new DateTime(1, yourMonthNumber, 1).ToString("MMMM")}
Also you can write your function on the Code tab in the begin of report, for example:

Code: Select all

using System;
using System.Drawing;
using System.Windows.Forms;
using System.Data;
using Stimulsoft.Controls;
using Stimulsoft.Base.Drawing;
using Stimulsoft.Report;
using Stimulsoft.Report.Dialogs;
using Stimulsoft.Report.Components;

namespace Reports
{
    
    public class Report : Stimulsoft.Report.StiReport
    {
		public string NumberToMonthName(int number)
		{
			if (number == 1) return "January";
			if (number == 2) return "February";
			if (number == 3) return "March";
			if (number == 4) return "April";
			if (number == 5) return "May";
			if (number == 6) return "June";
			if (number == 7) return "July";
			if (number == 8) return "August";
			if (number == 9) return "September";
			if (number == 10) return "October";
			if (number == 11) return "November";
			if (number == 12) return "December";
			return "";			
		}
		
        public Report()
        {
            this.InitializeComponent();
			.....
and then use this function in expressions, for example:

Code: Select all

{NumberToMonthName(yourMonthNumber)}
Thank you.

display name of the month

Posted: Mon May 03, 2010 9:42 pm
by reynard
:biggrin: thanks a lot... really work..

display name of the month

Posted: Mon May 10, 2010 10:55 am
by Andrew
Hello,

Perfect!

Thank you.