Site Sponsored By: SQLDSC - SQL Server Desired State Configuration
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.
Hi everyone!I tried the following:select*from tbl where d like '2008.03.25%'I want to have all entries from this day - why is it not working??thank u very much in advance and greetings from viennalandau
SELECT * FROM tbl WHERE Datediff(Day, d, '2008-03-25') = 0"God does not play dice" -- Albert Einstein"Not only does God play dice, but he sometimes throws them where they cannot be seen." -- Stephen Hawking
landau66
Yak Posting Veteran
61 Posts
Posted - 2008-08-26 : 16:23:17
Hi!Thanks for the answer. The datatype is datetime!But what would u do in this case:SELECT * FROM tbl WHERE d like '2008-03-25 09:%'?with this i want to get the entries from every day from 9 till under 10 Thanks a lotlandau
sorry to bother u again.i want the entries from ALL DAYS (more than one) between 9 and 10thanks, landau
Transact Charlie
Master Smack Fu Yak Hacker
3451 Posts
Posted - 2008-08-26 : 17:02:04
SELECT * FROM tbl WHERE datePart(HOUR, d) = 9-- I don't have access to a database server to check my syntax but think it should work.-------------Charlie
select columns from tablewhere dateadd(hour,datediff(hour,0,loggedin),0)>=dateadd(hour,9,dateadd(day,datediff(day,0,loggedin),0)) and dateadd(hour,datediff(hour,0,loggedin),0)<dateadd(hour,10,dateadd(day,datediff(day,0,loggedin),0))