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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Selecting paydates between macro-derived fields 1

Status
Not open for further replies.

ShaneSQ

Technical User
Nov 23, 2006
17
CA
I have two derived fields which return strings containing the date three days prior to the current date and three days after the current date. they are strings in the format that the Selection criteria uses when it's in SQL.

I have linked the macros to Before the report opens, but I still get "Invalid Column name".

Is there any way to make this do what I want?

Here's the SQL text, my macro text follows:
SELECT
SUM(DISTINCT @DECODE(REPORTS.V_DEDUCTIONS.DEDUCTIONCODE,'H',REPORTS.V_DEDUCTIONS.DEDUCTIONAMOUNT,0) ) , SUM(DISTINCT @DECODE(REPORTS.V_CHK_VW_DEDUCTION.CHECKVIEWDEDCODE,'H',REPORTS.V_CHK_VW_DEDUCTION.CHECKVIEWDEDAMT,0) ) , SUM(DISTINCT @DECODE(REPORTS.V_DEDUCTIONS.DEDUCTIONCODE,'B',REPORTS.V_DEDUCTIONS.DEDUCTIONAMOUNT,0) ) , SUM(DISTINCT @DECODE(REPORTS.V_CHK_VW_DEDUCTION.CHECKVIEWDEDCODE,'B',REPORTS.V_CHK_VW_DEDUCTION.CHECKVIEWDEDAMT,0) ) , ( SUM(DISTINCT @DECODE(REPORTS.V_DEDUCTIONS.DEDUCTIONCODE,'H',REPORTS.V_DEDUCTIONS.DEDUCTIONAMOUNT,0) ) ) - ( SUM(DISTINCT @DECODE(REPORTS.V_CHK_VW_DEDUCTION.CHECKVIEWDEDCODE,'H',REPORTS.V_CHK_VW_DEDUCTION.CHECKVIEWDEDAMT,0) ) ), ( SUM(DISTINCT @DECODE(REPORTS.V_DEDUCTIONS.DEDUCTIONCODE,'B',REPORTS.V_DEDUCTIONS.DEDUCTIONAMOUNT,0) ) ) - ( SUM(DISTINCT @DECODE(REPORTS.V_CHK_VW_DEDUCTION.CHECKVIEWDEDCODE,'B',REPORTS.V_CHK_VW_DEDUCTION.CHECKVIEWDEDAMT,0) ) ), @DECODE(REPORTS.V_DEDUCTIONS.COMPANYCODE,'K89','WCC','QH6','ICC','T4D','WAL','578','CT','CNQ','DCC','8OY','PG','?') , REPORTS.V_CHK_VW_DEDUCTION.CHECKVIEWPAYDATE, REPORTS.V_EMPLOYEE.NAME
FROM
REPORTS.V_DEDUCTIONS, REPORTS.V_CHK_VW_DEDUCTION, REPORTS.V_EMPLOYEE
WHERE
(((REPORTS.V_EMPLOYEE.EMPLOYEETYPE <> 'C') AND
(REPORTS.V_EMPLOYEE.STATUS <> 'T') AND
(REPORTS.V_CHK_VW_DEDUCTION.CHECKVIEWPAYDATE BETWEEN (threedaysagoDate) AND (threedaysafterDate))))
AND
(REPORTS.V_DEDUCTIONS.FILE# = REPORTS.V_EMPLOYEE.FILE# ) AND (REPORTS.V_CHK_VW_DEDUCTION.COMPANYCODE (+)= REPORTS.V_DEDUCTIONS.COMPANYCODE ) AND (REPORTS.V_CHK_VW_DEDUCTION.FILE# (+)= REPORTS.V_DEDUCTIONS.FILE# ) AND (REPORTS.V_CHK_VW_DEDUCTION.SOCIALINSURANCE# (+)= REPORTS.V_DEDUCTIONS.SOCIALINSURANCE# ) AND (REPORTS.V_CHK_VW_DEDUCTION.COMPANYCODE (+)= REPORTS.V_EMPLOYEE.COMPANYCODE ) AND (REPORTS.V_CHK_VW_DEDUCTION.FILE# (+)= REPORTS.V_EMPLOYEE.FILE# ) AND (REPORTS.V_CHK_VW_DEDUCTION.SOCIALINSURANCE# (+)= REPORTS.V_EMPLOYEE.SOCIALINSURANCE# )
GROUP BY
REPORTS.V_DEDUCTIONS.COMPANYCODE, REPORTS.V_DEDUCTIONS.FILE#, REPORTS.V_EMPLOYEE.NAME, REPORTS.V_EMPLOYEE.COMPANYCODE, REPORTS.V_EMPLOYEE.FILE#, REPORTS.V_EMPLOYEE.STATUS, REPORTS.V_CHK_VW_DEDUCTION.CHECKVIEWPAYDATE, REPORTS.V_DEDUCTIONS.SOCIALINSURANCE#, REPORTS.V_CHK_VW_DEDUCTION.COMPANYCODE, REPORTS.V_CHK_VW_DEDUCTION.FILE#, REPORTS.V_CHK_VW_DEDUCTION.SOCIALINSURANCE#, REPORTS.V_EMPLOYEE.SOCIALINSURANCE#, REPORTS.V_EMPLOYEE.EMPLOYEETYPE
HAVING
(( (((( SUM(DISTINCT @DECODE(REPORTS.V_DEDUCTIONS.DEDUCTIONCODE,'H',REPORTS.V_DEDUCTIONS.DEDUCTIONAMOUNT,0) ) ) - ( SUM(DISTINCT @DECODE(REPORTS.V_CHK_VW_DEDUCTION.CHECKVIEWDEDCODE,'H',REPORTS.V_CHK_VW_DEDUCTION.CHECKVIEWDEDAMT,0) ) )) > 0) OR
((( SUM(DISTINCT @DECODE(REPORTS.V_DEDUCTIONS.DEDUCTIONCODE,'B',REPORTS.V_DEDUCTIONS.DEDUCTIONAMOUNT,0) ) ) - ( SUM(DISTINCT @DECODE(REPORTS.V_CHK_VW_DEDUCTION.CHECKVIEWDEDCODE,'B',REPORTS.V_CHK_VW_DEDUCTION.CHECKVIEWDEDAMT,0) ) )) > 0))))
ORDER BY
REPORTS.V_EMPLOYEE.NAME

Here's the macro code for the date three days ago:

Sub threedaysagoDate()
Dim today as variant
Dim Daytodayval as variant
Dim Monthtoday as variant
Dim Yeartoday as variant
Dim threedaysagoDay as variant
Dim threedaysago as variant

today = Date$

Daytodayval=Val(Mid$(today,4,2))

Monthtoday=Left$(today, 2)

Yeartoday=Right$(today,4)

threedaysagoDay=(Daytodayval - 3)

threedaysagoDay = Ltrim$(str(threedaysagoDay))

threedaysago = str(Yeartoday + "-" + Monthtoday + "-" + threedaysagoDay)

DerivedField threedaysago

End Sub


Thank you for any and all help!
 
Is there any way to make this do what I want?

I don't think you told us "what I want?"

What are you trying to do?


CharlesCook.com
Specializing in ReportSmith Training and Consulting
 
Sorry, that was unclear.

I want to select for checkview paydates between the dates 3 days before the report is run to three days after the report is run.

So far I have Macro derived fields which return the date of 3 days previous to the report's run-date, and three days after. I have tried unsuccesfully to use these derived fields in the selections. I'm using the format YYYY-MM-DD. This is the format I saw the seletion criteria use when it is converted to SQL. I have tried linking the macros to the event Before SQL execution, again, to no avail.

Any help would be greatly appreciated,

Thank you!
 
I want to select for checkview paydates between the dates 3 days before the report is run to three days after the report is run.

Great I would use Selection Critera like this

data field REPORTS.V_CHK_VW_DEDUCTION.CHECKVIEWPAYDATE is between formula (SYSDATE - 3) and formula (SYSDATE + 3)

Am I missing something?


CharlesCook.com
Specializing in ReportSmith Training and Consulting
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top