Extract Decade from timestamp in Postgresql

In order to Extract Decade from timestamp in postgresql we will use EXTRACT() function. Let’s see how to

  • Extract Decade from timestamp in postgresql

We will be using student_detail table

extract decade from timestamp in postgresql 1

 

Extract Decade from timestamp in postgresql:

We will use extract() function along with keyword “DECADE” to extract decade from  timestamp in postgresql as shown below

SELECT *,EXTRACT (DECADE FROM Birthdaytime) AS DECADE FROM Student_detail

So the resultant dataframe with decade extracted from timestamp will be

extract decade from timestamp in postgresql 2

 

                                                                                                 

Author

  • Sridhar Venkatachalam

    With close to 10 years on Experience in data science and machine learning Have extensively worked on programming languages like R, Python (Pandas), SAS, Pyspark.