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 2005 Forums
 Transact-SQL (2005)
 strip out date and match

Author  Topic 

tech_1
Posting Yak Master

129 Posts

Posted - 2011-08-21 : 12:46:57
I have a table with a field "MembershipExpires". this is a datetime value and will contain time.

I want to strip out the time and find out where members expire on a given DATE

how would I do this with stripping out the time from the membershipExpires field?

jimf
Master Smack Fu Yak Hacker

2875 Posts

Posted - 2011-08-21 : 14:10:23
Not exactly sure what you're looking for, but the one of these should be helpful
declare @date datetime
set @date = getdate()
select dateadd(day,datediff(day,0,@date),0)
,dateadd(day,datediff(day,-1,@date),0)--<< you could use > and <= on these 2

select convert(varchar(8),@date,108)-- << looks like a time

Jim

Everyday I learn something that somebody else already knew
Go to Top of Page
   

- Advertisement -