Need EXTRACT function explanation

Database
The Teradata Database channel includes discussions around advanced Teradata features such as high-performance parallel database technology, the optimizer, mixed workload management solutions, and other related technologies.
Enthusiast

Need EXTRACT function explanation

Hi all,

Can anyone explain me the 3rd sql statment, as per my knowledge ( 04 -04) the o/p should be 0 but i get the o/p as 30 

 

 

1) SELECT CURRENT_DATE --O/P IS 4TH MAY 2017 i.e---05/04/2017

2) SEL EXTRACT(DAY FROM CURRENT_DATE + EXTRACT(DAY FROM CURRENT_DATE)) --- O/P is 8
3) SEL EXTRACT(DAY FROM CURRENT_DATE - EXTRACT(DAY FROM CURRENT_DATE)) --- O/P is 30


 

 

 

1 REPLY
Teradata Employee

Re: Need EXTRACT function explanation

If today is 2017-05-04, then

SEL EXTRACT(DAY FROM CURRENT_DATE - EXTRACT(DAY FROM CURRENT_DATE))

SEL EXTRACT(DAY FROM CURRENT_DATE - 4)

SEL EXTRACT(DAY FROM date'2017-04-30')

30