In order to typecast character or string to date in postgresql we will be using cast() function. With the help of cast() function we will be able to typecast character or string to date in postgresql. Let’s see how to
- Typecast Character or string to date in Postgresql
We will be using orders_new table.
Typecast character or string to date in Postgresql:
Method 1: Using :: to typecast
Column name followed by :: and followed by date is used to typecast received_text column.
select *,received_text::date as received_date 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 date is used to typecast received_text column.
select *,cast(received_text as date) as received_date from orders_new
So the resultant dataframe with received_text column typecasted will be