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 |
|
wizard007
Starting Member
2 Posts |
Posted - 2006-07-12 : 03:17:50
|
| I want to display some horse racing results I have on a page but I only want to show the results for the last 7 days.I have fields for date, time of race, horses name and result.How can I just get records within the last 7 days to display?I'm new to this SQL malarky so please be gentle! |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2006-07-12 : 03:19:13
|
[code]select *from tablewhere race_date_time >= dateadd(day, -7, getdate())[/code] KH |
 |
|
|
Q
Yak Posting Veteran
76 Posts |
Posted - 2006-07-12 : 03:19:46
|
| select *from [TABLE]where [RACEDATE] > getdate()-7 |
 |
|
|
wizard007
Starting Member
2 Posts |
Posted - 2006-07-13 : 03:56:27
|
| Hi,I tried the one at the bottom and just get this error message.MM_ERROR: MySQL Error#: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '[Date] > getdate()-7' at line 1I'm new to this SQL malarky so please be gentle! |
 |
|
|
chiragkhabaria
Master Smack Fu Yak Hacker
1907 Posts |
Posted - 2006-07-13 : 04:26:33
|
| oh this is MS SQL forum and the syntax which are listed above is for the SQL Server, for MYSQL try other forums like www.mysql.comChirag |
 |
|
|
|
|
|