Re: Extract date portion of a datetime field

From: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
To: JORGE MALDONADO <jorgemal1960(at)gmail(dot)com>
Cc: pgsql-novice <pgsql-novice(at)postgresql(dot)org>
Subject: Re: Extract date portion of a datetime field
Date: 2018-04-18 14:05:03
Message-ID: CAKFQuwZZyv5y7rFh3w1NJDVA5VU62OAt0o6jf_wfqwNnm32LkQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

On Wed, Apr 18, 2018 at 7:01 AM, JORGE MALDONADO <jorgemal1960(at)gmail(dot)com>
wrote:

> Hello,
>
> I have a table with a datetime field which saves (of course) date and time
> information. I need to design a query to count the number of records of
> each date without taking into account the time portion. I have seen that I
> can use functions like EXTRACT but I do not find how to extract the whole
> date only.
>

​select ('2018-04-18T12:24:36'::timestamptz)::date
select to_char(('2018-04-18T12:24:36'::timestamptz), 'YYYY-MM-DD')

David J.​

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message Stephen Froehlich 2018-04-18 19:35:35 RE: Extract date portion of a datetime field
Previous Message Scott Ford 2018-04-18 14:04:19 Re: Extract date portion of a datetime field