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 |
|
John T.
Posting Yak Master
112 Posts |
Posted - 2003-08-24 : 15:26:52
|
| Good afternoon. Beautiful day in Maryland. I have a program on the order of a fantasy football league. Members make selections and about 10 minutes after the game begins, those selections are made public. No problem(knock on wood) with that.However, I want to be able to do the following. Show the total number of picks that have been made for the day by all the members. Whether the games have started or not. My problem seems to be the early morning hours. Even at 4am, I want the total plays made for the day before showing. Until I feed into the system the scores and then grade them to start over.CREATE PROCEDURE CountTodays @varInt SMALLINT OUTPUT ASSelect @varInt = count (*) from DailyTableWhere convert(varchar(25),GTime,1) = convert(varchar(25), DateAdd(d,0,GetDate()),1)The above is what I have. I may have a mistake?? with using the GetDate() function, as I have used GetUTCDate() in most of my code to eliminate the chance of server being in who knows what time zone.The GTime values have the time with the date. That is how I determine when they can me made available for public view.Thanks.John |
|
|
simondeutsch
Aged Yak Warrior
547 Posts |
Posted - 2003-08-24 : 17:23:27
|
Your code seems correct, however, 2 things:1. why are you using the DATEADD function if you are adding 0 days, or rather, not adding anything, but just using GETDATE()?2. a performance note: your query is not SARGable (Search Arguments- cannot make use of an index by the query optimizer). You would probably like to change the WHERE clause to WHERE GTime BETWEEN @Date AND DATEADD(d,1,@Date) where @Date is a date you pass in that you want to query, with no time, which defaults to 12 AM. You can easily add a @Date input parameter to the procedure to solve all the converting/casting problems to get rid of times.Sarah Berger MCSD |
 |
|
|
|
|
|
|
|