Building Reports Using ASP.NET and Crystal Reports - Part 4: Dynamic Grouping
page 6 of 9
by Vince Varallo
Feedback
Average Rating: 
Views (Total / Last 10 Days): 71448/ 157

Step 5: Create the Date Formulas

This report will allow the user to group by the year, quarter, month, or week of the employee's hire date. To do this you need to create a formula for each.

1.    Right click on the Formula Fields node in the Field Explorer window.

2.    Select New… from the pop-up menu and enter HireYear for the name. Click the Use Editor button.

3.    Enter the following formula.

Listing 1

totext(year({Employee.HireDate}), 0, '')

This converts the year of hire to text and tells Crystal to use no decimals or thousands separator.

4.    Click the Save and close button.

5.    Do the same for the other formulas. Here is the code for each.

Listing 2

HireQuarter:

totext(Year ({Employee.HireDate}), 0, "") + "-" + totext(DatePart ("q", 
      {Employee.HireDate}), 0, "")

HireMonth:

totext(Year ({Employee.HireDate}), 0, "") + "-" + totext(Month 
      ({Employee.HireDate}), 0, "")

HireWeek:

totext(Year ({Employee.HireDate}), 0, "") + "-" + totext(DatePart ("w", 
      {Employee.HireDate}), 0, "")

View Entire Article

User Comments

Title: CRystal REports Dynamically   
Name: Naresh
Date: 12/7/2012 11:48:18 PM
Comment:
Good
Title: t   
Name: n
Date: 12/7/2012 11:47:21 PM
Comment:
ertt
Title: Another nice article   
Name: Rick
Date: 12/1/2009 4:02:34 PM
Comment:
Easy to follow and godd explainations. Thanks for taking the time to put this article together. I have gone through the other 3 parts and really getting a better feel fot the reports
Title: ASP.NET Crystal Reports Hosting   
Name: Helen
Date: 10/13/2009 8:46:44 PM
Comment:
I real like this article and I could learn more things about Crystal Reports
Thanks

___________________________________________________
http://www.webhost4lifereview.com/crystal-report-web-hosting/
Title: Can anybody help me please?   
Name: Beto
Date: 10/2/2009 12:40:03 PM
Comment:
What's up? I hope you help me... I want to have a report that has 3 pages per sheet... How can I do that? Thanks beforehand =)
Title: Very Nice Artical   
Name: Gaurav Gupta
Date: 9/24/2009 5:13:31 AM
Comment:
Dear Vince Varallo

The article is really great.It is very useful to understand crystal report. And the way of communicating is also very simple.

Thanks
Gaurav Gupta
Title: Problem   
Name: Pankaj Rai
Date: 9/18/2009 2:16:54 AM
Comment:
Dear Vince Varallo,

I have to made a crystal report which show the sum of amount datewise. And also to display all the transaction on particular date when I click on date feild in crystal report.Is there any technique to pass date as parameter for subreport.Please reply ASAP.


Thanks in Advance.
Title: Really Nice Artical   
Name: Pankaj Rai
Date: 9/18/2009 2:13:10 AM
Comment:
I have read this and learn something good regarding crystal report.

Thanks
Title: Very Good   
Name: Edwin
Date: 9/10/2009 10:56:39 AM
Comment:
I have been reading all the 4 parts and its very very usefull. Thanks a million. Just on more wish !!

VB code along with C# would have been amazing. Does your book has VB code as well as C#?

Product Spotlight
Product Spotlight 



Community Advice: ASP | SQL | XML | Regular Expressions | Windows


©Copyright 1998-2014 ASPAlliance.com  |  Page Processed at 10/23/2014 9:06:16 AM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search