Home Page for the TeradataForum
 

Archives of the TeradataForum

Message Posted: Mon, 03 Mar 2003 @ 16:51:09 GMT


     
  <Prev Next>  
<<First
<Prev
Next> Last>>  


Subj:   Dynamic date calculations
 
From:   shivaji

Hi All ,

Here are few dynamic date calculations I did it for BO .Hope this will help you ..


Regards

Shivaji


Current Month
---------------------
sel cast(current_date  as DATE)  (FORMAT 'MM')     or
sel extract(month from current_date)               or
sel month(current_date)

Previous Month
-----------------------

MONTH(add_months(current_date,-1))

Last Day of Last month
------------------------------------

sel cast(cast ( ('01-'||cast(current_date as date FORMAT 'MM-YYYY') ) as
date FORMAT 'DD-MM-YYYY') as date format 'YYYY-MM-DD') -1

Previous Year
---------------------
sel YEAR(current_date)-1

Prevous Year month
-------------------------------
sel CAST(add_months(current_date,-1) AS DATE)( FORMAT 'YYYYMM')

Current Week Starting
----------------------------------

  sel  min(calendar_date)
  from sys_calendar.calendar
  where day_of_week = '7'
  and calendar_Date  between (current_date - 7) and current_date

Previous Week Starting
----------------------------------
sel  min(calendar_date)
from sys_calendar.calendar
 where day_of_week = '7'
and calendar_Date  between (current_date - 14) and (current_date -7)

Shivaji Sekaramantri



     
  <Prev Next>  
<<First
<Prev
Next> Last>>  
 
 
 
 
 
 
 
 
  
  Top Home Privacy Feedback  
 
 
Copyright for the TeradataForum (TDATA-L), Manta BlueSky    
Copyright 2016 - All Rights Reserved    
Last Modified: 15 Jun 2023