Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Date and Count

Author  Topic 

nezbo
Starting Member

1 Post

Posted - 2007-03-05 : 10:03:15
Hi all, i am prity new to sql and am just learning (that hard way)


I have this code and i am trying to get out of it: a date with the number of calles that have been taken on that date between 2 dates.


SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED

DECLARE @DisplayFrom as DATETIME
DECLARE @DisplayTo as DATETIME
DECLARE @FromDate as DATETIME
DECLARE @ToDate as DATETIME

SET @DisplayFrom = <%FromDate|Enter start date%>
SET @DisplayTo = <%ToDate|Enter end date%>
SET @FromDate = dbo.fUniversalTime(@DisplayFrom)
SET @ToDate = dbo.fUniversalTime(@DisplayTo)

SELECT SUM(ActiveDate), ActiveDate
FROM
(SELECT DISTINCT (ActiveDate) from [case])as T

where ActiveDate between @FromDate and @ToDate

group by ActiveDate



e.g. output

01/02/07 52
02/02/07 63
etc...

hope this makes sence

Neil

snSQL
Master Smack Fu Yak Hacker

1837 Posts

Posted - 2007-03-05 : 13:05:18
Are you using SQL Server? If not then this probably won't work, but your query should be something like:
SELECT convert(varchar(10), ActiveDate, 3), count(*)
FROM [case]
where ActiveDate between @FromDate and @ToDate
group by convert(varchar(10), ActiveDate, 3)
Go to Top of Page
   

- Advertisement -