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 |
|
jung1975
Aged Yak Warrior
503 Posts |
Posted - 2004-07-28 : 23:27:50
|
I have a table which has person_ID and account_create_date Person_id account_create_date----------------------------------1001 2004-07-28 09:15:15.1601002 2004-07-28 14:15:15.1601003 2004-07-28 15:15:15.1601004 2004-07-28 20:04:15.1601005 2004-07-28 20:15:15.160 ...I would like to find out a list of people who have created an account 2hours ago( from getdate).For example, if the current time is 10:00 pm ,the output should looks like:1004 2004-07-28 20:04:15.1601005 2004-07-28 20:15:15.160[/code]something likewhere account_create_date > datepart(hh,getdate) - 2 |
|
|
timmy
Master Smack Fu Yak Hacker
1242 Posts |
Posted - 2004-07-28 : 23:36:31
|
| You're close...SELECT PersonID, CreateDateFROM tableWHERE DateDiff(hh, CreateDate, GetDate()) <= 2 |
 |
|
|
Pat Phelan
Posting Yak Master
187 Posts |
Posted - 2004-07-28 : 23:37:03
|
How about:where account_create_date > DateAdd(hour, -2, GetDate()) -PatP |
 |
|
|
|
|
|