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 |
BaldEagle
Starting Member
23 Posts |
Posted - 2002-04-04 : 23:56:14
|
I always had a problem getting the date that matches with a date in the database. I have a database table with a column that contains the date/time. How can i write an SQL Statement to match all those records that has a date which is 1 day before today's date? Anyone can help me? Thanks :) |
|
Merkin
Funky Drop Bear Fearing SQL Dude!
4970 Posts |
Posted - 2002-04-05 : 00:12:13
|
HiYou can use the DateDiff function for this. In your caseSELECT * FROM TableWHERE DateDiff(d, YourDateField, GetDate()) = 1 Hope that helpsDamian |
|
|
BaldEagle
Starting Member
23 Posts |
Posted - 2002-04-05 : 00:19:16
|
hey i works, i do not know i can do itin this way. Thanks man !! :) |
|
|
Merkin
Funky Drop Bear Fearing SQL Dude!
4970 Posts |
Posted - 2002-04-05 : 00:23:29
|
No worries. Also, if you wanted to match today, you could just change the number to 0Damian |
|
|
|
|
|