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 |
|
BuzzParker
Starting Member
5 Posts |
Posted - 2009-08-25 : 19:46:21
|
| My table has a date field and I am trying to select data for the last 30 days. Here is what I have but I keep getting errors.Set stable = Server.CreateObject("ADODB.Recordset")stable.ActiveConnection = MM_ADODB_STRINGstable.Source = "SELECT * FROM dbo.stable where date between " & "'" & now() & "'" & " and " & "'" & now() - 30 & "'"stable.CursorType = 0stable.CursorLocation = 2stable.LockType = 1stable.Open()If I just do sstatstable.Source = "SELECT * FROM dbo.sstatstable"it works fine.Any help would be greatly appreciated. |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2009-08-26 : 03:19:45
|
BETWEEN operator needs the first value to be the smallest and the second value the largest.Set stable = Server.CreateObject("ADODB.Recordset")With stable .ActiveConnection = MM_ADODB_STRING .Source = "SELECT * FROM dbo.stable where date between '" & (now() - 30) & "' and '" & now() & "'" .CursorType = 0 .CursorLocation = 2 .LockType = 1 .Open()End With N 56°04'39.26"E 12°55'05.63" |
 |
|
|
BuzzParker
Starting Member
5 Posts |
Posted - 2009-08-26 : 15:24:52
|
| That was it. Thank you very much. |
 |
|
|
|
|
|