Extract date part from timestamp in Postgresql

In order to Extract date part from timestamp in postgresql we will first typecasting them to timestamp and then date. Let’s see how to

  • Extract date part from timestamp in Postgresql

We will be using student_detail table.

Extract date part from timestamp in Postgresql 1

 

 

Extract date part from timestamp in postgresql:

we will first typecaste the column to timestamp and then typecaste to date as shown below, which in turn keeps only the date value which will result in extracting date from timestamp


select *,birthdaytime :: timestamp :: date  from student_detail

So the resultant dataframe with date extracted from timestamp will be

Extract date part 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.