· Due within Days:
TimestampDiff(SQL_TSI_DAY,CURRENT_DATE,"Time Dimension"."Date")
· Days Past Due:
TimestampDiff(SQL_TSI_DAY, "Time Dimension"."Date",CURRENT_DATE)
· Calculate current year with Current quarter:
EVALUATE ('TO_CHAR(%1,%2)' AS CHARACTER ( 30 ), CURRENT_DATE, 'YYYY-Q')
· Calculate previous year’s Current Year with previous year’s current quarter:
EVALUATE ('TO_CHAR(%1,%2)' AS CHARACTER ( 30 ), TIMESTAMPADD( SQL_TSI_YEAR , -1, CURRENT_DATE), 'YYYY-Q')
· Calculate current year with current fiscal quarter:
EVALUATE ('TO_CHAR(%1,%2)' AS CHARACTER ( 30 ), CURRENT_DATE, 'YYYY')||'-'||CAST("Time Dim"."Fiscal Quarter" AS char)
· Calculate previous year’s current year with previous year’s current fiscal quarter:
EVALUATE ('TO_CHAR(%1,%2)' AS CHARACTER ( 30 ), TIMESTAMPADD( SQL_TSI_YEAR , -1, CURRENT_DATE), 'YYYY')||'-'||CAST("Time Dim"."Fiscal Quarter" AS char)
· First Day of the CURRENT Month:
TIMESTAMPADD(SQL_TSI_DAY, -1,TIMESTAMPADD(SQL_TSI_MONTH,1,TIMESTAMPADD(SQL_TSI_DAY,1,TIMESTAMPADD(SQL_TSI_DAY, DAYOFMONTH(CURRENT_DATE)*-1, CURRENT_DATE))))
· Last Day of Current Month
TIMESTAMPADD( SQL_TSI_DAY , -(1), TIMESTAMPADD( SQL_TSI_MONTH , 1, TIMESTAMPADD( SQL_TSI_DAY , DAYOFMONTH( CURRENT_DATE) * -(1) + 1, CURRENT_DATE)))
· First Day of the Previous Month
TIMESTAMPADD(SQL_TSI_MONTH, -1, TIMESTAMPADD( SQL_TSI_DAY , DAYOFMONTH( CURRENT_DATE) * -(1) + 1, CURRENT_DATE))
· Last Day of the Previous Month
TIMESTAMPADD( SQL_TSI_DAY , -(1), TIMESTAMPADD( SQL_TSI_DAY , DAYOFMONTH( CURRENT_DATE) * -(1) + 1, CURRENT_DATE))
· First Day of the Next Month
TIMESTAMPADD(SQL_TSI_MONTH, 1, TIMESTAMPADD( SQL_TSI_DAY , DAYOFMONTH( CURRENT_DATE) * -(1) + 1, CURRENT_DATE))
· Last Day of the Next Month
TIMESTAMPADD( SQL_TSI_DAY , -(1), TIMESTAMPADD( SQL_TSI_MONTH , 2, TIMESTAMPADD( SQL_TSI_DAY , DAYOFMONTH( CURRENT_DATE) * -(1) + 1, CURRENT_DATE)))
· First Day of the Current Year
TIMESTAMPADD( SQL_TSI_DAY , EXTRACT( DAY_OF_YEAR FROM CURRENT_DATE) * -(1) + 1, CURRENT_DATE)
· Last Day of Current Year
TIMESTAMPADD(SQL_TSI_YEAR, 1, TIMESTAMPADD( SQL_TSI_DAY , -1, TIMESTAMPADD( SQL_TSI_DAY , EXTRACT( DAY_OF_YEAR FROM CURRENT_DATE) * -(1) + 1, CURRENT_DATE)))
· First Day of the Previous Year
TIMESTAMPADD( SQL_TSI_YEAR , -1, TIMESTAMPADD( SQL_TSI_DAY , EXTRACT( DAY_OF_YEAR FROM CURRENT_DATE) * -(1) + 1, CURRENT_DATE))
· Last Day of Previous Year
TIMESTAMPADD( SQL_TSI_DAY , -1, TIMESTAMPADD( SQL_TSI_DAY , EXTRACT( DAY_OF_YEAR FROM CURRENT_DATE) * -(1) + 1, CURRENT_DATE))
· First Day of the Next Year
TIMESTAMPADD( SQL_TSI_YEAR , 1, TIMESTAMPADD( SQL_TSI_DAY , EXTRACT( DAY_OF_YEAR FROM CURRENT_DATE) * -(1) + 1, CURRENT_DATE))
· Last Day of the Next Year
TIMESTAMPADD(SQL_TSI_YEAR, 2, TIMESTAMPADD( SQL_TSI_DAY , -1, TIMESTAMPADD( SQL_TSI_DAY , EXTRACT( DAY_OF_YEAR FROM CURRENT_DATE) * -(1) + 1, CURRENT_DATE)))
· First Day of Current Quarter
TIMESTAMPADD( SQL_TSI_DAY , DAY_OF_QUARTER( CURRENT_DATE) * -(1) + 1, CURRENT_DATE)
· Last Day of Current Quarter
TIMESTAMPADD( SQL_TSI_DAY , -(1), TIMESTAMPADD( SQL_TSI_QUARTER , 1, TIMESTAMPADD( SQL_TSI_DAY , DAY_OF_QUARTER( CURRENT_DATE) * -(1) + 1, CURRENT_DATE)))
· Number of days between First Day of Year and Last Day of Current Month
DAYOFYEAR(CURRENT_DATE)
Pretty helpful information.
ReplyDeleteIn my obi report I have a date column, I want to display the max(date) in that column.
ReplyDeleteWhen I use Max() it's not fetching the max date record.
Please could you help us regarding this.
Thanks
Does anyone have a code for First Day of Previous Quarter?
ReplyDeleteTIMESTAMPADD( SQL_TSI_QUARTER , -(1), TIMESTAMPADD( SQL_TSI_DAY , DAY_OF_QUARTER( CURRENT_DATE) * -(1) + 1, CURRENT_DATE))
Deletehow to write code for 22nd of last month to 22nd of current month?
DeleteTry RANK
ReplyDeleteCan someone help with with first and last day of the current month of previous year.
ReplyDeleteHow to calculate sales(measure column) based on current month last date fiscal year ?
ReplyDelete