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
 SQL Server 2000 Forums
 Transact-SQL (2000)
 query help

Author  Topic 

esthera
Master Smack Fu Yak Hacker

1410 Posts

Posted - 2005-08-29 : 04:21:17
can someone help me adjust the following query

select count(id) as hits from hits where [date] >= CONVERT(datetime, '8/28/2005', 101) AND [Date] < CONVERT(datetime, '8/29/2005', 101) and filesource=2

I want to add to this that the ip of the hit (also in hits table) is unique from 12 midnight of the previous night

Kristen
Test

22859 Posts

Posted - 2005-08-29 : 06:55:57
CONVERT(datetime, '8/28/2005', 101)

The "format" 3rd parameter for CONVERT only works when converting from a datetime to text.

You need

SET DATEFORMAT mdy
SELECT ... where [date] >= CONVERT(datetime, '8/28/2005') ...

Kristen
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-08-29 : 07:09:20
Use Datetime variable to have that date and pass datevalue in yyyymmdd format
Then there wont be any need of conversion

Madhivanan

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

- Advertisement -