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.
| Author |
Topic |
|
adlo
Posting Yak Master
108 Posts |
Posted - 2004-09-16 : 08:06:35
|
| What is the most efficient sql statement to do the following:I need to get a list of users (e-mail addresses) who were created yesterday.The UserTable :User_ID,EMail,DateCreated(DateTime) |
|
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2004-09-16 : 08:12:15
|
IMHO:select * from UserTable where day(DateCreated) = day(dateadd(d, -1, getdate()))Go with the flow & have fun! Else fight the flow |
 |
|
|
adlo
Posting Yak Master
108 Posts |
Posted - 2004-09-16 : 08:36:49
|
| I need a query that gives back only yesterday's entries and should not include yesterday a month/year ago. |
 |
|
|
robvolk
Most Valuable Yak
15732 Posts |
Posted - 2004-09-16 : 08:38:35
|
| A little tweak:SELECT * FROM userTable WHERE DateDiff(day, DateCreated, getdate())=-1 |
 |
|
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2004-09-16 : 08:41:23
|
hey that is kool!! Go with the flow & have fun! Else fight the flow |
 |
|
|
adlo
Posting Yak Master
108 Posts |
Posted - 2004-09-16 : 08:45:06
|
| Thanks robvolkThe query I had previouslyselect Email from UserTable where CONVERT(CHAR(10),DateCreated,111) = CONVERT(CHAR(10),dateadd(d, -1, getdate()),111)New querySELECT * FROM Accountuser WHERE DateDiff(day, DateCreated, getdate())=1 |
 |
|
|
|
|
|
|
|