Bee Positive
Bee Positive

Reputation: 37

How to cut off timestamp from date in postgresql?

The current data in the s_date column 2018-05-04 00:00:00

I want to it display in the format of 4/5/2018

Below is my script in Postgresql:

SELECT * 
FROM table_namewhere CAST(s_date AS VARCHAR) LIKE '%2018%'

Upvotes: 1

Views: 1501

Answers (1)

user330315
user330315

Reputation:

Assuming s_date is defined as timestamp or date, you can use to_char()

select to_char(s_date, 'dd/mm/yyyy') as formatted_date
from the_table;

Upvotes: 2

Related Questions