Month and Year function

1 Answer 5408 Views
Report Designer (standalone)
Narender
Top achievements
Rank 1
Narender asked on 14 Mar 2016, 10:53 AM

Hi All,

I have a date field in my sql query.

I want to create a report in which i want to show Current year(2016) and previous year(2015) data only.In the same way i want to show current month and previous month data.

 

So can someone tell me how i can convert my date to current year and the previous year or current nonth and previous year.

 

I am using Standalone report designer.

 

Thanks,

 

Narender

1 Answer, 1 is accepted

Sort by
0
Nasko
Telerik team
answered on 16 Mar 2016, 02:15 PM
Hello Narender,

The built-in Date and Time Functions can be used to retrieve the current date. Using the DateTime Properties you can find the previous month/year inside an expression:

Current year:       = Now().Year
Previous year:     = Now().Year - 1
Current month:    = Now().Month
Previous month:  = Now().Month - 1


Regards,
Nasko
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Narender
Top achievements
Rank 1
commented on 17 Mar 2016, 12:13 PM

Thanks Nasko,

I will try and get back to you.

 

Narender

Narender
Top achievements
Rank 1
commented on 21 Mar 2016, 07:07 AM

Hi Nasko.

Its really helpful.

I am able to use Now() function .

 

But i am facing a problem.

when ever i used Now().year function in cloumn heading , it gives me year like 2016 but in data in that coumn is showing 2014,2015,2016 as i am using (fields.order_year).

 

So i want to know how i can control  to take only 2016 year as i am using now().year in column heading,

I have a column of order date  and i have created year through this  order date.Now i want to show sum(amount) against current year of order date .means  2016 and employe id.

 

like :

 

employe id    now().year   amount

1                      2016               50

2                       2016              60

 

now().year is the column of order date of 2016.

 

Only those data whose order is year 2016.

 

Please tell me expression or any suggestion.

 

Thanks,

 

Narender

Nasko
Telerik team
commented on 21 Mar 2016, 12:51 PM

Hello Narender,

You can use Filtering to show data only for the current year.

Regards,
Nasko
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Narender
Top achievements
Rank 1
commented on 22 Mar 2016, 11:54 AM

Hello Nasko,

As you suggested , I have applied filter on table and sucessfully got 2016 year result.

But this fiter option is available in property of table when i select whole table . How i can apply filter on item of table .

To take result like this:-

 

employe id    now().year                   now().year-1
1                      sum(amount)              sum(amount) 
2                       sum(amount)            sum(amount) 

 

 

Thanks,

 

Narender

Nasko
Telerik team
commented on 23 Mar 2016, 03:42 PM

Hello Narender,

The described structure can be achieved by creating column groups for the table. You can use the Group Explorer window to add column groups to your table, or you can use the Crosstab item.

Regards,
Nasko
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Narender
Top achievements
Rank 1
commented on 29 Mar 2016, 10:47 AM

Hello ,

 I have used the column group 2015 and 2016 year with but it is showing all rows which want to include means 2014 year rows also included in table as showing in figure.

Note: 2014 year rows showing blank as used in both 2015 and 2016 year column.

want to 2014 year rows . How can achieve this??

 

can you tell me how can use "in " operation for 2015 and 2016 year

 

like 

fields.year in (2015,2016)

It is showing error when apply this filter in row group.Please tell me to use IN operator too.

 

 

Thanks,

 

Narender

Simon
Top achievements
Rank 1
commented on 29 Oct 2018, 08:10 AM

Hello,

in my report I have a datetimepicker with the name "Zeitraum" as reportparameter.

My simple question is:

How can I format this component, so that the datetimepicker will show only the months?

In the report.designer.cs file I have the following code:

            this.objectDataSource1.DataMember = "GetDriverDetails";
            this.objectDataSource1.DataSource = typeof(ReportLibraryTest.MyData);
            this.objectDataSource1.Name = "objectDataSource1";
            this.objectDataSource1.Parameters.AddRange(new Telerik.Reporting.ObjectDataSourceParameter[] {
            new Telerik.Reporting.ObjectDataSourceParameter("date", typeof(System.DateTime), "= Parameters.Zeitraum.Value"),
           

 

Ivan Hristov
Telerik team
commented on 31 Oct 2018, 04:36 PM

Hi Simon,

The type of the editor used in the parameter's area is determined by the parameter type. When the parameter is of type DateTime, a DateTimePicker will always be used, except if a custom one is provided. You can check this article that explains how to create a custom parameter editor for HTML5-based report viewer: How To: Create a Custom Parameter Editor. For WPF viewer the editor's properties can be changed through the themes templates. WinForms report viewer does not provide a straight-forward way to use a custom parameter editor, so in this case the solution is to implement a new UI for report parameters.

Hope this helps.

Regards,
Ivan Hristov
Progress Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
Report Designer (standalone)
Asked by
Narender
Top achievements
Rank 1
Answers by
Nasko
Telerik team
Share this question
or