DanCaparroz
DanCaparroz

Reputation: 820

Count query grouping by date ignoring time

I have a DATE variable that should be grouped ignoring the time in this query:

SELECT COUNT(*), update_date
FROM table1
HAVING count(update_date)>1
GROUP BY update_date
ORDER BY update_date desc

The result is right but I need to group them by the DAY and not by seconds since the date format of the field is DD/MM/YYYY HH:MM:SS. I would like to compare only the DD/MM/YYYY, ignoring the time of the update, by day.

Upvotes: 0

Views: 192

Answers (1)

user330315
user330315

Reputation:

Use trunc() to set the time part to 00:00:00:

SELECT COUNT(*), trunc(update_date) as update_date
FROM table1
GROUP BY trunc(update_date)
HAVING count(trunc(update_date))>1
ORDER BY trunc(update_date) desc

Upvotes: 3

Related Questions