×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • 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!
  • Students Click Here

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

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Selecting paydates between macro-derived fields

Selecting paydates between macro-derived fields

Selecting paydates between macro-derived fields

(OP)
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!

RE: Selecting paydates between macro-derived fields

Quote:

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

RE: Selecting paydates between macro-derived fields

(OP)
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!

RE: Selecting paydates between macro-derived fields

Quote:

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

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

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! Already a Member? Login

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