display name of the month

Stimulsoft Reports.WPF discussion
Post Reply
reynard
Posts: 5
Joined: Thu Apr 29, 2010 10:24 pm

display name of the month

Post 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..
Jan
Posts: 1265
Joined: Thu Feb 19, 2009 8:19 am

display name of the month

Post by Jan »

Hello,

For example:

Code: Select all

{Today.ToString("MMMM")}
Thank you.
reynard
Posts: 5
Joined: Thu Apr 29, 2010 10:24 pm

display name of the month

Post by reynard »

how about if i want to make something like this:

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

is it possible?
Ivan
Posts: 960
Joined: Thu Aug 10, 2006 1:37 am

display name of the month

Post 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.
Attachments
406.Report months sample.zip
(1.61 KiB) Downloaded 356 times
reynard
Posts: 5
Joined: Thu Apr 29, 2010 10:24 pm

display name of the month

Post by reynard »

:biggrin: thanks a lot... really work..
Andrew
Posts: 4108
Joined: Fri Jun 09, 2006 3:58 am

display name of the month

Post by Andrew »

Hello,

Perfect!

Thank you.
Post Reply