In order to typecast character or string to timestamp in postgresql we will be using cast() function. With the help of cast() function we will be able to typecast character or string to timestamp in postgresql. Let’s see how to
- Typecast Character or string to timestamp in Postgresql
We will be using orders_new table.
Typecast character or string to timestamp in Postgresql:
Method 1: Using :: to typecast
Column name followed by :: and followed by timestamp is used to typecast received_text column.
select *,received_text::timestamp as received_timestamp from orders_new
So the resultant dataframe with received_text column typecasted will be
Method 2: Using CAST() function to typecast
CAST() function with Argument column_name as timestamp is used to typecast received_text column.
select *,cast(received_text as timestamp) as received_timestamp from orders_new
So the resultant dataframe with received_text column typecasted will be