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

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


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


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


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

View Entire Article

User Comments

Title: CRystal REports Dynamically   
Name: Naresh
Date: 2012-12-07 11:48:18 PM
Title: t   
Name: n
Date: 2012-12-07 11:47:21 PM
Title: Another nice article   
Name: Rick
Date: 2009-12-01 4:02:34 PM
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: 2009-10-13 8:46:44 PM
I real like this article and I could learn more things about Crystal Reports

Title: Can anybody help me please?   
Name: Beto
Date: 2009-10-02 12:40:03 PM
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: 2009-09-24 5:13:31 AM
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.

Gaurav Gupta
Title: Problem   
Name: Pankaj Rai
Date: 2009-09-18 2:16:54 AM
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: 2009-09-18 2:13:10 AM
I have read this and learn something good regarding crystal report.

Title: Very Good   
Name: Edwin
Date: 2009-09-10 10:56:39 AM
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-2018  |  Page Processed at 2018-05-27 9:45:35 AM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search