Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Link using month

Status
Not open for further replies.

Ofina

Technical User
Feb 25, 2004
156
US
I have two tables with dates in them. I need to link these two in CR XI by the month they are in and not the exact day.

How do I do this? Can I even do this?
 
Hi,
youi could create a Command and use Sql to join the tables:
This is how, in Oracle, your syntax may vary
Code:
Select * from table1 t1,table2 t2
where
To_Char(t1.Date-Field,'MM') =  To_Char(t2.DateField,'MM')

Otherwise, you ned to use a subreport and create formulas to link them.





[profile]

To Paraphrase:"The Help you get is proportional to the Help you give.."
 
I'm having trouble figuring out how to use SQL commands in Crystal. I know the sql code I need just fine.

Do I create an SQL command that contains the record selection in its entirety? If so, I'm getting an error on that.

Or do I just use it to contain the join for those particular tables? If so, how on earth do I do that?
 
Yes, the command should include the record selection formula. You should be entering this in database->database expert->your datasource->add command (above the list of tables).

An easy way to see how a command should be built is to create a report that uses that desired tables that you have linked in the database expert, and with a record selection formula that successfully is incorporated into the SQL query. Then go to database->show SQL query and copy the SQL you see there into a new report that uses the command as the datasource. If you are using parameters, you should create those within the command screen.

-LB
 
If you prefer not to use the SQL approach, you could do the following:
Create a formula field that extracts the year and month. Use the DatePart function or the ToText function to do this.
Create a sub-report using the second table and create the same formula. Place the sub-report in the proper section and link on the formula fields.


Howard Hammerman,
Crystal Training and Crystal Material
On-site classes and one-on-one coaching
Low-cost telephone/email support
FREE independent Crystal newsletter
howard@hammerman.com
800-783-2269
 
Nope, I did it and it's working fine.
Thanks.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top