Web Development

General discussion


Grouping dates into days

By bop_zw ·
I am trying to group a date Range result set of say one month into days between 22:00:00 and 21:59:59. I's this possible with SQL or do I have to do it in my .NET application?

This conversation is currently closed to new comments.

Thread display: Collapse - | Expand +

All Comments

Collapse -

by phillip.griffiths-owens In reply to Grouping dates into days

try this:

SELECT * FROM yourTbl WHERE [date] BETWEEN 'startdate' AND 'enddate'

Collapse -

by bop_zw In reply to

That will return a result set that is NOT grouped! My problem is how do I group records of the same date but different times?

Collapse -

by Tony Hopkinson In reply to Grouping dates into days

I hope you're reading these you semm to have sacttered this question all over the place.
Depends on what dbms and mind spotty memory but
Select DatePart(Day,MydateField) DayNo, Sum(Value)
From MyTable
Group By DayNo

or something close should do the trick

Collapse -

by itpreneur In reply to Grouping dates into days

select day(vardate) from table
where vardate between
startdate and enddate
group by day(vardate)
order by day

Related Discussions

Related Forums