Smart questions
Smart answers
Smart people
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

Join Tek-Tips
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

LINK TO THIS FORUM!

Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

Partner With Us!

"Best Of Breed" Forums Add Stickiness To Your Site
Partner Button
(Download This Button Today!)

Feedback

"...What you have done for people like me is immeasurably helpful."

Geography

Where in the world do Tek-Tips members come from?
John1Chr (TechnicalUser)
6 Jun 12 13:29
I'm using crystal 8.5 and within the SQL Expression Editor I want to prevent pulling in future date if it is 7/1/2013 or greater. Other than that I want the max effective date.

My current formula is:


(SELECT MAX(EFFDT)
FROM TABLE TABLE2
WHERE TABLE2.CT_VALUE = TABLE.CT_VALUE and
TABLE2.CFATTRIB = TABLE.CFATTRIB)
hilfy ( IS/IT--Management)
7 Jun 12 14:58
Try something like this (you don't specify your database so I'm going to assume Oracle - change the syntax as needed for your DB):
(
Select MIN(MYDATE)
from
(SELECT MAX(EFFDT)as MYDATE FROM TABLE TABLE2WHERE TABLE2.CT_VALUE = TABLE.CT_VALUE and TABLE2.CFATTRIB = TABLE.CFATTRIB
UNION ALL
Select '01-JUL-2013' as MYDATE from Dual)
)

-Dell

A computer only does what you actually told it to do - not what you thought you told it to do.

John1Chr (TechnicalUser)
20 Jun 12 14:13
I'm getting this error - ODBC error MS dbase engine can't find the input table or query 'Dual". Make sure it exists and its name is spelled correctly.

Is it possible to put if the table CFATTRIB is PROG or ACT then select if less than 7/1/2013? CFATTRIB can have up to 10 different attributes to it and I only want to focus on the PROG and ACT attributes in that field.
hilfy ( IS/IT--Management)
20 Jun 12 16:26
"Dual" is an Oracle thing. You should be able to remove the "From" part of the bottom of the union and you'll probably need to convert the string for the date into an actual date - Oracle will do the conversion automatically when the date string is in the format 'dd-MON-yyyy'.

-Dell

DecisionFirst Technologies - Six-time SAP BusinessObjects Solution Partner of the Year
www.decisionfirst.com

John1Chr (TechnicalUser)
21 Jun 12 8:01
Hi - getting error query must contain at least one table or query after removing the from Dual. (Ended with MyDate)

Also received another error that followed - Syntax error before the first MIN.
hilfy ( IS/IT--Management)
21 Jun 12 9:28
You'll need to go into a database query tool such as Toad or SQL Server Management Studio to develop your query. I have not used much SQL Server, so I can't help you with that.

-Dell

DecisionFirst Technologies - Six-time SAP BusinessObjects Solution Partner of the Year
www.decisionfirst.com

John1Chr (TechnicalUser)
21 Jun 12 14:42
I think I'm almost there. I'm using in a Select formula like this and it pushes me back to the beginning MAX it doesn't like my date. If I use < Date (2013,07,01) flat out in the crystal record selection formula editor it works fine without the formula. It will not work in the formula though. I can't get the date to work in SQL Expression Editor for the formula below -

(SELECT MAX(TABLE2.EFFDT)
FROM TABLE TABLE2
WHERE TABLE2.CT_VALUE = TABLE.CT_VALUE and
TABLE2.CFATTRIB = TABLE.CFATTRIB
AND ( (TABLE2.CFATTRIB not in ('PROG','ACT') or TABLE2.EFFDT < '01 Jul
2013')) )
hilfy ( IS/IT--Management)
21 Jun 12 15:41
You'll probably need to convert the string version of the date to a date in your SQL in order to get this working.

-Dell

DecisionFirst Technologies - Six-time SAP BusinessObjects Solution Partner of the Year
www.decisionfirst.com

John1Chr (TechnicalUser)
21 Jun 12 16:02
You're talking about converting the MAX(TABLE2.EFFDT) beginning and the TABLE2.EFFDT < '01 Jul 2013')) ) to the Date (2013,07,01) format correct? Crystal doesn't have a TODATE function. Not sure exactly how I would do this in the SQL Expression Editor. Is there a formula that I can try?
John1Chr (TechnicalUser)
22 Jun 12 8:25
I'm thinking that I need to convert to DATETIME. That is the format on the ODBC Oracle table.
hilfy ( IS/IT--Management)
22 Jun 12 9:35
Yes, and because this is a SQL Expression, you can't use any Crystal functions - you have to do it in the correct syntax for your database.

-Dell

DecisionFirst Technologies - Six-time SAP BusinessObjects Solution Partner of the Year
www.decisionfirst.com

John1Chr (TechnicalUser)
22 Jun 12 10:24
Is there a way in the record selection formula to say if the table CFATTRIB is PROG or ACT then select if effective date is less than 7/1/2013?

CFATTRIB can have up to 10 different attributes to it and I only want to focus on the PROG and ACT attributes in that field. Currently, I have a SQL expression field that pulls in max effect date for all 10 attributes:

(SELECT MAX(EFFDT)
FROM TABLE TABLE2
WHERE TABLE2.CT_VALUE = TABLE.CT_VALUE and
TABLE2.CFATTRIB = TABLE.CFATTRIB)

Problem is that when I say in the Record Selection Formula Editor TABLE.EFFDT = {%maxeffdt} AND TABLE.EFFDT < Date (2013,07,01) it completely removes the attribute that has any effdt exceeding 7/1/2013. It will not grab the attribute that has a max eff date less than 7/1/2013 - rather completely removes the PROG or ACT from the report.
John1Chr (TechnicalUser)
22 Jun 12 11:34
I'm really thrown by the date. I know that the table that it is reading from is in DATE/TIME format and it accepts if I put EFFDT < '7/1/2013' in the SQL Expression Editor query. but when I run the report it bombs data type mismatch. Somehow the SQL needs to be converted to Date (YYYY,MM,DD) when it is read in the record selection formula editor. I think.
IanWaterman (Programmer)
22 Jun 12 11:57
TRy

<Convert(DateTime, '07/01/2013' , 102)

102 = US Format MM/DD/YYYY
103 = UK DD/MM/YYYY

Ian
John1Chr (TechnicalUser)
22 Jun 12 13:27
It didn't take. The actual format in that field is '7/1/2013 12:00:00AM'. So when I put the Max effect Date SQL Expression Editor formula in the Record selection formula editor it bombs. It bombs if I try to place in the report, also.

Might need to go back to the drawing board.sad
John1Chr (TechnicalUser)
22 Jun 12 13:56
it does work if I put the crystal funciton EFFDT < {fn NOW()})) ) at the end. It filters out the dates before now.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close