MY SQL-Count number of trancation occure in particular time
-
Hi, I have table which has coloumn,name as Transaction Time. now i want tocount number of transaction occure in between 1am to 2am(like every hour)on same day how can i do this? :omg: :((
-
Hi, I have table which has coloumn,name as Transaction Time. now i want tocount number of transaction occure in between 1am to 2am(like every hour)on same day how can i do this? :omg: :((
Hi , Below is the data of the 'Transaction' table: Data TransactionTime ---------------------------------------- A11 2009-07-09 16:21:15.173 A22 2009-07-09 16:50:15.000 A33 2009-07-09 17:21:15.000 A44 2009-07-02 16:21:15.000 A55 2009-07-20 16:51:15.000 A66 2009-07-10 16:21:15.000 A77 2009-07-09 18:21:15.000 Now if you need to get the count of every thursday(5th day) between (4 to 5 pm) here is the query: select count(*) from Transaction where datepart(dw,TransactionTime) = 5 and datepart(Hh,TransactionTime) + datepart(Mm,TransactionTime) * .017 between 16 and 17 Note: "datepart(Mm,TransactionTime) * .017 " will convert minutes into hours so that you can exactly get the data between 16:00 to 17:00 (hh:mm). group by convert(varchar, TransactionTime, 103)