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
 Issue with Dates

Author  Topic 

kathyc2003
Starting Member

15 Posts

Posted - 2006-10-24 : 13:48:03
Hello,
I have written the procedure shown below and I prompt the user for a start date/time and end date/time. Format is:
12/06/2006 1:51:32 AM

My query does not give me the correct results - what have I done wrong?

(my sample code)

CREATE PROCEDURE [dbo].[CaseProcedure]
(@StartDate DATETIME, @EndDate DATETIME)

AS

SELECT
I.CFScompanyname, E.CreatedOn,
E.TicketNumber, E.OwningUser, U.FirstName,

U.LastName
FROM IncidentExtensionBase I
INNER JOIN IncidentBase E ON I.IncidentId =

E.IncidentId
INNER JOIN SystemUserBase U ON E.OwningUser

= U.SystemUserId
WHERE E.createdon >= @StartDate) AND

E.createdon <= @EndDate

ORDER BY E.CreatedOn DESC;
GO


snSQL
Master Smack Fu Yak Hacker

1837 Posts

Posted - 2006-10-24 : 13:50:38
quote:
My query does not give me the correct results - what have I done wrong?

I have no idea - you didn't say what the correct results should be or what incorrect results you're getting.
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2006-10-24 : 13:51:25


Well just what are the correct results suppose to be?

Read the hint link in my sig and post what it asks for



Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx

Add yourself!
http://www.frappr.com/sqlteam



Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2006-10-24 : 14:17:30
This is your query, formatted for easier reading
SELECT		I.CFScompanyname,
E.CreatedOn,
E.TicketNumber,
E.OwningUser,
U.FirstName,
U.LastName
FROM IncidentExtensionBase I
INNER JOIN IncidentBase E ON I.IncidentId = E.IncidentId
INNER JOIN SystemUserBase U ON E.OwningUser = U.SystemUserId
WHERE E.createdon >= @StartDate)
AND E.createdon <= @EndDate
ORDER BY E.CreatedOn DESC
I'll give you a hint. It has to do with a missing paranthesis to do...


Peter Larsson
Helsingborg, Sweden
Go to Top of Page

rockmoose
SQL Natt Alfen

3279 Posts

Posted - 2006-10-24 : 15:51:20
I was not going to comment this topic, but...

Now I really do understand why they call you the "Patron Saint" !!!

________
Karma

rockmoose
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-10-24 : 23:03:19
If paranthesis is missing then the questioner should have got error than wrong results?

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

jezemine
Master Smack Fu Yak Hacker

2886 Posts

Posted - 2006-10-24 : 23:31:19
maybe what they mean by "wrong results" is this: Incorrect syntax near ')'.



SqlSpec - a fast, cheap, and comprehensive data dictionary generator for SQL Server 2000 and 2005 - http://www.elsasoft.org
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-10-25 : 06:44:31
quote:
Originally posted by jezemine

maybe what they mean by "wrong results" is this: Incorrect syntax near ')'.



SqlSpec - a fast, cheap, and comprehensive data dictionary generator for SQL Server 2000 and 2005 - http://www.elsasoft.org


Yes. It is not wrong result but Error

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2006-10-25 : 07:31:10
Or the poster omitted every fourth and/or third row from query in case we accidentally could figure out what was happening?


Peter Larsson
Helsingborg, Sweden
Go to Top of Page
   

- Advertisement -