I am working on a query to provide a calculated due date. I have gotten all my dates to return in their columns, but the Expression to return the ultimate a single date is escaping me!
To calculate the "due date" as 10 days prior to the TERM_BEGIN_DT (use field as CALC_DUE_DT in Expression): %DateAdd(%datein(A.TERM_BEGIN_DT), -10)
To get today's date (one of many ways, again in Expression): %CurrentDateIn
SQL of query working thus far:
SELECT DISTINCT A.INSTITUTION, A.ACAD_CAREER, A.STRM, TO_CHAR(A.TERM_BEGIN_DT,'YYYY-MM-DD'), ((TO_DATE(TO_CHAR(A.TERM_BEGIN_DT,'YYYY-MM-DD'),'YYYY-MM-DD')) + ( -10)), TO_DATE(TO_CHAR(SYSDATE,'YYYY-MM-DD'),'YYYY-MM-DD')
FROM PS_TERM_TBL A
WHERE ( A.INSTITUTION = :1
AND A.ACAD_CAREER = :2
AND A.STRM = :3)
GROUP BY A.INSTITUTION, A.ACAD_CAREER, A.STRM, A.TERM_BEGIN_DT, TO_DATE(TO_CHAR(SYSDATE,'YYYY-MM-DD'),'YYYY-MM-DD')

Next Step - do the comparison and return a single date!
Basically I want to end up with this as a column for end use:
IF %CurrentDateIn > CALC_DUE_DT THEN CALC_DUE_DT
ELSE %CurrentDateIn
End
I am having fits with using the Expression when most of what I find is designed to be used in AppDesigner as pure SQL. This leads to %DateIn vs. %DateOut for Select vs. From portions of SQL. That doesn't help a whole lot in Expression! I have tried all the combinations I could think of including reusing the TO_DATE(TO_CHAR)... stuff - no dice. I either get "the FROM is in an unexpected place" or some other less useful error.
The most annoying thing is I can use these Expressions as straight-up criteria and it works, but only to show everything or a null:
SELECT A.INSTITUTION, A.ACAD_CAREER, A.STRM, TO_CHAR(A.TERM_BEGIN_DT,'YYYY-MM-DD'), ((TO_DATE(TO_CHAR(A.TERM_BEGIN_DT,'YYYY-MM-DD'),'YYYY-MM-DD')) + ( -10)), TRUNC(SYSDATE)
FROM PS_TERM_TBL A
WHERE ( A.INSTITUTION = :1
AND A.ACAD_CAREER = :2
AND A.STRM = :3)
GROUP BY A.INSTITUTION, A.ACAD_CAREER, A.STRM, A.TERM_BEGIN_DT, TRUNC(SYSDATE)
HAVING ( ((TO_DATE(A.TERM_BEGIN_DT,'YYYY-MM-DD')) + ( -10)) <= TRUNC(SYSDATE))
Would someone with more experience/patience on Dates be able to help get me going on this Expression? Much appreciation for any walk through of how I'm not getting the proper exit off of this freeway!
------------------------------
Joanna Schmidt
Sr. Business Analyst - Financial Aid
Maricopa Community College System Office
joanna.schmidt@domail.maricopa.edu------------------------------