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
 count

Author  Topic 

midpenntech
Posting Yak Master

137 Posts

Posted - 2008-11-17 : 10:59:13
how would i create a count on a between date range. example
(ardate between '1/1/2008' AND GETDATE())

I want it to count the days from what ever ardate pulls back to current date and END AS Days.

sakets_2000
Master Smack Fu Yak Hacker

1472 Posts

Posted - 2008-11-17 : 11:14:28
If you're looking for count of days between 2 dates, Use datefiff function.
Go to Top of Page

sakets_2000
Master Smack Fu Yak Hacker

1472 Posts

Posted - 2008-11-17 : 11:15:21
quote:
Originally posted by sakets_2000

If you're looking for count of days between 2 dates, Use datefiff function.



I'm sorry, I meant DATEDIFF.

select datediff(day,getdate(),getdate()+4)
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-11-17 : 11:18:36
wont select datediff(dd,ardate,GETDATE()) be enough? or are you looking at

select count(*) from table where ardate between '1/1/2008' AND GETDATE()
Go to Top of Page
   

- Advertisement -