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
 SQL Server Development (2000)
 prevoius date irrespective of time in sql

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2003-11-12 : 08:25:46
tim writes "i need the previuos date irrespective of time
i have written
select * from cs_members where EXP_DATE = getdate() - 1 and TYPE_OF_ACC = 'T'

but it is not showing any records
Can you tell me how will i get the recors irrespective of time in datetime"

ehorn
Master Smack Fu Yak Hacker

1632 Posts

Posted - 2003-11-12 : 08:59:08
select convert(varchar(12),getdate()-1,101)
Go to Top of Page

drymchaser
Aged Yak Warrior

552 Posts

Posted - 2003-11-12 : 09:02:43
This is one way.
DECLARE @start, @end varchar(25)

SELECT @start = CONVERT(varchar(10), DATEADD(dd, -1, GETDATE()), 101) + '00:00:00'
SELECT @end = CONVERT(varchar(10), DATEADD(dd, -1, GETDATE()), 101) + '23:59:59'

SELECT *
FROM cs_members
WHERE TYPE_OF_ACC = 'T'
AND EXP_DATE BETWEEN @start AND @end
Go to Top of Page
   

- Advertisement -