Hello
All,
Please find the time-stamp important query. All timestamp query
are very important while developing the Report.
Yesterday’s Date_yesterday
Current Day : Current_Date
Last week Week function : is
between @{Date_7_Days_Ago} and @{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))
First Day of the Current Year
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)).
First Day of the Previous Month
TIMESTAMPADD(SQL_TSI_MONTH, -1, TIMESTAMPADD( SQL_TSI_DAY , DAYOFMONTH(
CURRENT_DATE) * -(1) + 1, CURRENT_DATE))
First
Day of the Current Month
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))
First Day of Current Quarter
TIMESTAMPADD( SQL_TSI_DAY , DAY_OF_QUARTER( 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))
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))) .
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)))
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))
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)))
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)))
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
TIMESTAMPDIFF(SQL_TSI_DAY,
CAST('2010/01/01 00:00:00' AS DATE), TIMESTAMPADD( SQL_TSI_DAY , -(1),
TIMESTAMPADD( SQL_TSI_MONTH , 1, TIMESTAMPADD( SQL_TSI_DAY , DAYOFMONTH(
CURRENT_DATE) * -(1) + 1, CURRENT_DATE))))
Thanks you
-Rakesh Patil
-rakeshpatil002@gmail.com