Saturday, June 22, 2013

SQL/OBIEE: Query CURRENT YEAR / QUARTER / MONTH

To query current year, current quarter and current month, run below query:

SELECT
TRUNC(cast(TO_CHAR(SYSDATE,'YYYY') as VARCHAR(20))),
TRUNC(CAST(TO_CHAR(SYSDATE,'Q') AS VARCHAR(20))),
TRUNC(CAST(TO_CHAR(SYSDATE,'MM') AS VARCHAR(20)))
FROM DUAL;

OBIEE 11g Note: This query can also be used in OBIEE RPD in defining Repository Initialization Block (Repository Variable) to use CURRENT_YEAR, CURRENT_QUARTER, CURRENT_MONTH rather than Session variable.

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.