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 all,i wanna to perform like search on datetime fieldcan anybody help me to solve this issuethanks in advanceregardsDurgesh J
webfred
Master Smack Fu Yak Hacker
8781 Posts
Posted - 2008-12-10 : 04:43:00
LIKE is for characters.You can use BETWEEN to search a range of datetime.WebfredNo, you're never too old to Yak'n'Roll if you're too young to die.
bklr
Master Smack Fu Yak Hacker
1693 Posts
Posted - 2008-12-10 : 04:43:52
can u explain ur requirement
Transact Charlie
Master Smack Fu Yak Hacker
3451 Posts
Posted - 2008-12-10 : 04:45:30
You probably want DATEPARTI take it you want to query months / years / days?You could so something like
WHERE DATEPART(YEAR,<yourcolumn>) = 2008 AND DATEPART(DAY,<yourcolumn>) = 1
to find all 1st of the month entries in 2008 for exampleCharlie===============================================================Msg 3903, Level 16, State 1, Line 1736The ROLLBACK TRANSACTION request has no corresponding BEGIN TRANSACTION
visakh16
Very Important crosS Applying yaK Herder
52326 Posts
Posted - 2008-12-10 : 09:13:25
seems like intention for this is to get records for a day without considering timepart. in that case you need just this
WHERE datecolumn >=DATEADD(dd,DATEDIFF(dd,0,GETDATE()),0)AND datecolumn <DATEADD(dd,DATEDIFF(dd,0,GETDATE()),1)