I would like to group my sales qry by a 24 hr time period other than the standard group by day. Our sales periods go from 7:30pm to 7:30pm. I have searched several datetime grouping post but can't find exactly what I am looking for. TIA for your help.
QRY so far...
DECLARE @SDate as datetime
DECLARE @EDate as datetime
Set @SDate = '2006-08-31 19:30:00'
Set @EDate = '2006-09-20 19:29:59'
select p.invoiceid, p.processeddate, p.paymentamount, sum(p.paymentamount)
from payments p
Inner JOIN orders o on p.orderid = o.orderid
where p.ProcessedDate >= @SDate
and p.ProcessedDate < @EDate
and o.contractitemid = 2585
and p.paymentamount > 0
and p.paymenttype = 'initial'
and p.status = 'Y'
group by p.invoiceid, p.processeddate, p.paymentamount
order by p.processeddate
QRY so far...
DECLARE @SDate as datetime
DECLARE @EDate as datetime
Set @SDate = '2006-08-31 19:30:00'
Set @EDate = '2006-09-20 19:29:59'
select p.invoiceid, p.processeddate, p.paymentamount, sum(p.paymentamount)
from payments p
Inner JOIN orders o on p.orderid = o.orderid
where p.ProcessedDate >= @SDate
and p.ProcessedDate < @EDate
and o.contractitemid = 2585
and p.paymentamount > 0
and p.paymenttype = 'initial'
and p.status = 'Y'
group by p.invoiceid, p.processeddate, p.paymentamount
order by p.processeddate