monkeybarfan
MIS
- Feb 23, 2005
- 116
I have a Crystal Report that counts up all weekend calls, by month. I have created a Crystal formula to perform this - I am trying to recreate this in a stored procedure to use elsewhere, but the results are quite different.
SELECT
Datepart(yy,CONVERT(DateTime, CONVERT(varchar(10), [STARTDATE], 103), 103)) as 'Year',
Datepart(mm,CONVERT(DateTime, CONVERT(varchar(10), [STARTDATE], 103), 103)) as 'Month',
COUNT(CLID) as 'CLID'
FROM STCLLREC
WHERE Datename(dw,STARTDATE)='Sunday'
OR Datename(dw,STARTDATE)='Saturday'
This is not working. I have also tried using Datepart(dw, STARTDATE)=1 and it makes no difference. I am sure the Crystal Report is right, because I have drilled down into the actual details.
Can anyone spot anything? The data all comes off one table, so there are no joins or anything.
SELECT
Datepart(yy,CONVERT(DateTime, CONVERT(varchar(10), [STARTDATE], 103), 103)) as 'Year',
Datepart(mm,CONVERT(DateTime, CONVERT(varchar(10), [STARTDATE], 103), 103)) as 'Month',
COUNT(CLID) as 'CLID'
FROM STCLLREC
WHERE Datename(dw,STARTDATE)='Sunday'
OR Datename(dw,STARTDATE)='Saturday'
This is not working. I have also tried using Datepart(dw, STARTDATE)=1 and it makes no difference. I am sure the Crystal Report is right, because I have drilled down into the actual details.
Can anyone spot anything? The data all comes off one table, so there are no joins or anything.