Tuesday, May 25, 2010

OBIEE TimeStamp Calculations:

David T showed some nice Timstamp calculations on the OTN forum:

http://forums.oracle.com/forums/message.jspa?messageID=4315664#4315664

1) TIMESTAMPADD(SQL_TSI_DAY, (DayOfMonth(CURRENT_DATE))*-1, CURRENT_DATE) will give you the last day of the previous month...


2) TIMESTAMPADD(SQL_TSI_DAY,DAYOFWEEK(TIMESTAMPADD(SQL_TSI_DAY, (DayOfMonth(CURRENT_DATE))*-1, CURRENT_DATE))*-1,TIMESTAMPADD(SQL_TSI_DAY, (DayOfMonth(CURRENT_DATE))*-1, CURRENT_DATE)) will give you the Saturday prior to the last week of the month.


3) TIMESTAMPADD(SQL_TSI_DAY,1,TIMESTAMPADD(SQL_TSI_DAY,DAYOFWEEK(TIMESTAMPADD(SQL_TSI_DAY, (DayOfMonth(CURRENT_DATE))*-1, CURRENT_DATE))*-1,TIMESTAMPADD(SQL_TSI_DAY, (DayOfMonth(CURRENT_DATE))*-1, CURRENT_DATE))) will give you the Sunday of the last week of the previous month.

Till Next Time

No comments: