Now that you are connected to the database you can add your
fields to the report. Any fields that you want to show up as line items in the
report should be placed in the Details section.
1.
In the Field Explorer click the plus sign next to Database Fields.
Click the plus sign next to SalesHeader to view the fields in this table.
2.
Drag the SalesDate and Total fields to the details section in the
report. Crystal will automatically add the column headers to the Page Header
section when you drop fields into the details section.

3.
Now we'll create a formula field to display the Quarter of the
SalesDate. Right click on the Formula Fields node in the Field Explorer and
select New… from the pop-up menu. Enter Quarter for the formula name and click
the Use Editor button.

4.
Crystal has numerous built in functions that you can use in your own
formulas. The functions are listed in the Functions pane in the Formula
Editor. Click the plus sign next to the Functions node and then click the plus
sign next to the Date and Time node. This will display the list of available
functions to manipulate dates. The one we are looking for is called DatePart.
If you scroll down the Date and Time node you should see this function. Be
aware that the functions aren't listed in alphabetical order so you have to
scroll down near the bottom of the list.
5.
The DatePart function has three different signatures. If you click the
plus sign next to the DatePart node you'll see the three signatures. Double
click on the first signature and it will then appear in the body of the
formula.

6.
The first parameter to the DatePart function is the interval. The
interval can be year (yyyy), quarter (q), month (m), day (d), hour (h), minute
(n), second (s), day of week (w), and week (ww). Enter 'q' so that the quarter
is retrieved from the date.
7.
The second parameter is the date expression that should be evaluated. This
is the SalesDate field in the SalesHeader table. The formula text should
appear as follows.
DatePart ('q', {SalesHeader.SalesDate})
8.
Click the Save and close button. The Quarter formula will now appear
under the Formula Fields node in the Field Explorer.
9.
Drag the Quarter function to the details section. Click the Main Report
Preview button to display the report. You should see either 1 or 2 for the
quarter.
