Forums

This topic is locked

SQL RS Filter Help

Posted 23 May 2002 23:15:32
1
has voted
23 May 2002 23:15:32 Peter Lent posted:
Hi All,

I have the following SQL statement that is "supposed" to only pull records that have been created in the last 24 hours. It is sort of working, it pulls in records within the 24 hour period, but they have to be created in the prior day. If I create a record today, then run the page that has the SQL it does not pull the record. If I manually change the date to yesterday it works fine.

I need help since I am very green to SQL.

THANKS

SQL CODE:
SELECT *
FROM breaking
WHERE (((breaking.breakdate)>=Date()-1) AND ((breaking.breaktime)>=Time()))


THANKS

-Peter

Replies

Replied 24 May 2002 09:13:01
24 May 2002 09:13:01 Viktor Farcic replied:
SELECT *
FROM breaking
WHERE breaking.breakdate>=(DateAdd(Day, - 1, Date()))

<BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote>
Hi All,

I have the following SQL statement that is "supposed" to only pull records that have been created in the last 24 hours. It is sort of working, it pulls in records within the 24 hour period, but they have to be created in the prior day. If I create a record today, then run the page that has the SQL it does not pull the record. If I manually change the date to yesterday it works fine.

I need help since I am very green to SQL.

THANKS

SQL CODE:
SELECT *
FROM breaking
WHERE (((breaking.breakdate)&gt;=Date()-1) AND ((breaking.breaktime)&gt;=Time()))


THANKS

-Peter

<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>

Viktor Farcic

TalkZone Manager
Replied 24 May 2002 16:23:56
24 May 2002 16:23:56 Peter Lent replied:
When I use the SQL provided I get this error

"Microsoft OLE DB Provider for ODBC Drivers error '80040e10'

[Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 1.

/index.asp, line 17 "

Here is the entire code for the RS:
&lt;%
set rsBreak = Server.CreateObject("ADODB.Recordset"
rsBreak.ActiveConnection = MM_socal_STRING
rsBreak.Source = "SELECT * FROM breaking WHERE breaking.breakdate&gt;=(DateAdd(Day, - 1, Date()))"
rsBreak.CursorType = 0
rsBreak.CursorLocation = 2
rsBreak.LockType = 3
rsBreak.Open()
rsBreak_numRows = 0
%&gt;

Any suggestions?

THANKS

-Peter
Replied 24 May 2002 16:51:41
24 May 2002 16:51:41 Viktor Farcic replied:
What DB are you using? If it's SQL Server then replace Date() with GetDate().

<BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote>
When I use the SQL provided I get this error

"Microsoft OLE DB Provider for ODBC Drivers error '80040e10'

[Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 1.

/index.asp, line 17 "

Here is the entire code for the RS:
&lt;%
set rsBreak = Server.CreateObject("ADODB.Recordset"
rsBreak.ActiveConnection = MM_socal_STRING
rsBreak.Source = "SELECT * FROM breaking WHERE breaking.breakdate&gt;=(DateAdd(Day, - 1, Date()))"
rsBreak.CursorType = 0
rsBreak.CursorLocation = 2
rsBreak.LockType = 3
rsBreak.Open()
rsBreak_numRows = 0
%&gt;

Any suggestions?

THANKS

-Peter
<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>

Viktor Farcic

TalkZone Manager
Replied 24 May 2002 16:55:30
24 May 2002 16:55:30 Peter Lent replied:
I am using a MS Access DB File. The format of my date field is Date/Time.

My ulimate goal is make a record expire (not be pulled into the RS) if it was created more than 24 hours ago.

THANKS

-Peter

Reply to this topic