9

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?

CQM
  • 42,592
  • 75
  • 224
  • 366
  • 1
    The trouble is probably from using a timestamp instead of a date. Try using `to_date`. What type of data does the `day` attribute hold that is making this function necessary? – cms_mgr Feb 04 '13 at 16:44

2 Answers2

29

please, try

SELECT date_trunc(...)::date;
Pavel Stehule
  • 42,331
  • 5
  • 91
  • 94
4

You can use to_date to specify your date format

TO_DATE(date_col, 'yyyy-mm-dd')
Matheus
  • 281
  • 2
  • 5