RE: Extract date portion of a datetime field

From: Stephen Froehlich <s(dot)froehlich(at)cablelabs(dot)com>
To: JORGE MALDONADO <jorgemal1960(at)gmail(dot)com>, pgsql-novice <pgsql-novice(at)postgresql(dot)org>
Subject: RE: Extract date portion of a datetime field
Date: 2018-04-18 19:35:35
Message-ID: CY1PR0601MB12109FFDAACD8F5101A60500E5B60@CY1PR0601MB1210.namprd06.prod.outlook.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

If its already saved as a timestamp with timezone (or timestamp without timezone) in postgres, then date_trunc(‘day’, [field_name]) will do the trick.

--Stephen

From: JORGE MALDONADO <jorgemal1960(at)gmail(dot)com>
Sent: Wednesday, April 18, 2018 8:01 AM
To: pgsql-novice <pgsql-novice(at)postgresql(dot)org>
Subject: Extract date portion of a datetime field

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.

I will very much appreciate your feedback.

Respectfully,
Jorge Maldonado

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message Chris Campbell 2018-04-18 22:18:48 Distinct Counts
Previous Message David G. Johnston 2018-04-18 14:05:03 Re: Extract date portion of a datetime field