CQM
CQM

Reputation: 44228

postgres sql, date_trunc without extra zeroes

This is an excerpt from my sql query

SELECT
date_trunc(
    'day',
    to_timestamp(requests.date_created)
)AS DAY,

this is my output 2013-02-04 00:00:00+00

I want this to be just 2013-02-04

how do I get the desired result?

Upvotes: 11

Views: 13286

Answers (2)

Matheus
Matheus

Reputation: 291

You can use to_date to specify your date format

TO_DATE(date_col, 'yyyy-mm-dd')

Upvotes: 5

Pavel Stehule
Pavel Stehule

Reputation: 45835

please, try

SELECT date_trunc(...)::date;

Upvotes: 34

Related Questions