Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Group by Date rather than DateTime

cjpicc11Jul 9 2015 — edited Jul 9 2015

Hello,

I am trying to look for counts that are grouped by date vs. date time.  For example, I am running the below query.

ALTER session SET NLS_DATE_FORMAT = 'mm/dd/yyyy';

select count(distinct contact_id) as counts, created as created_date

from s_con_chrctr

where created >= TO_CHAR('07/01/2015') and created <= TO_CHAR('07/10/2015')

and created_by = '1-J9455J'

group by created;

The results are as follows.

COUNTSCREATED_DATE
107/02/2015
107/02/2015
107/02/2015
107/02/2015

I believe this is happening because this date column is a datetime column and its bringing back a record for each specific time within that day.  The results I am looking for are...

COUNTSCREATED_DATE
1507/02/2015
1707/03/2015
3507/04/2015
1107/05/2015

How would I change my query in order to group by the date and not by date time?

This post has been answered by GregV on Jul 9 2015
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 6 2015
Added on Jul 9 2015
4 comments
34,930 views