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.
| Author |
Topic |
|
php95saj
Starting Member
43 Posts |
Posted - 2002-08-09 : 07:50:06
|
| I am trying to get a count of countries on Jobs table between to show how many jobs were submitted between two dates from each country.here is somethign I was thinking to do but it doesn't work:declare @dateFrom datetime, @dateTo datetimeSET @dateFrom = '8/1/01'SET @dateTo = '8'8'02SELECT COUNT(tblJobs.countryID)FROM tblJobsWHERE DATEDIFF(d, @dateFrom, tblJobs.jobCompletionDate) >=0AND DATEDIFF(d, @dateTo, tblJobs.jobCompletionDate) <=0GROUP BY tblJobs.countryID |
|
|
nr
SQLTeam MVY
12543 Posts |
Posted - 2002-08-09 : 08:10:31
|
| always use dates in yyyymmdd format then you won't get format problems.declare @dateFrom datetime, @dateTo datetime SET @dateFrom = '20010801' SET @dateTo = '20020808' SELECT COUNT(*) FROM tblJobs where tblJobs.jobCompletionDate < @dateToand tblJobs.jobCompletionDate >= @dateFromor maybeSELECT COUNT(*) FROM tblJobs where tblJobs.jobCompletionDate between @dateFrom and @dateTo==========================================Cursors are useful if you don't know sql.DTS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
|
|
|
|