Forums
This topic is locked
pull records createded within 24 hours
Posted 14 May 2002 23:35:57
1
has voted
14 May 2002 23:35:57 Peter Lent posted:
Hi All,I am trying to create an on-line system that will only show records that
have been created in the last 24 hours.
I am automatically inserting the date/time when the record is created into
"date and "time" field.
When the records are pulled form the DB (access) I only want to have records
that have been created in the 24 hours appear.
How can I do this?
My table is called "breaking"
date field "date"
time field "time"
THANKS
-Peter
Replies
Replied 15 May 2002 02:00:26
15 May 2002 02:00:26 Andrew Watson replied:
Well this can be looked at from an easy perspective or a a trickier one.
If it is simply the records created today then just filter the date field equal to todays date...
Recordset1.Fields.Item("date" = Date()
or if it has to be within the last 24 hours exactly! Then, if its 5.00 pm now then show the records created since 5.00 pm yesterday. So you need to filter for records that have a time greater than the time now and a date that is 1 day before today...(now being runtime!)
look up info on the 'DateDiff' VBScript function it should get you what you want.....
Cheers
Leed
:: Son, im Thirty.... ::
If it is simply the records created today then just filter the date field equal to todays date...
Recordset1.Fields.Item("date" = Date()
or if it has to be within the last 24 hours exactly! Then, if its 5.00 pm now then show the records created since 5.00 pm yesterday. So you need to filter for records that have a time greater than the time now and a date that is 1 day before today...(now being runtime!)
look up info on the 'DateDiff' VBScript function it should get you what you want.....
Cheers
Leed
:: Son, im Thirty.... ::
Replied 15 May 2002 08:11:27
15 May 2002 08:11:27 Dave Clarke replied:
I have a recordset that displays records for the last week and the filter looks like this
<b>SELECT *
FROM Messages
WHERE ((Messages.MessageDate>Date()-7))
ORDER BY Messages.MessageDate DESC;</b>
obviously you have to have a date field in your database, change the <b>-7</b>to <b>-1</b>and you have messages from yesterday. how to do it exactly 24 hrs from runtime i have no idea.
Dave
<b>SELECT *
FROM Messages
WHERE ((Messages.MessageDate>Date()-7))
ORDER BY Messages.MessageDate DESC;</b>
obviously you have to have a date field in your database, change the <b>-7</b>to <b>-1</b>and you have messages from yesterday. how to do it exactly 24 hrs from runtime i have no idea.
Dave
Replied 15 May 2002 10:09:18
15 May 2002 10:09:18 Andrew Watson replied:
<pre id=code><font face=courier size=2 id=code>
<%= DateAdd("h",-24,Now()) %>
</font id=code></pre id=code>
Exactly 24 hours before runtime.
:: Son, im Thirty.... ::
<%= DateAdd("h",-24,Now()) %>
</font id=code></pre id=code>
Exactly 24 hours before runtime.
:: Son, im Thirty.... ::
Replied 15 May 2002 17:03:33
15 May 2002 17:03:33 Peter Lent replied:
Hi Leed,
How would the statement below work into my SQL? Obviously I am new at ASP/SQL.
THANKS
-Peter
<
<%= DateAdd("h",-24,Now()) %>
Exactly 24 hours before runtime.
:: Son, im Thirty.... ::
>
How would the statement below work into my SQL? Obviously I am new at ASP/SQL.
THANKS
-Peter
<
<%= DateAdd("h",-24,Now()) %>
Exactly 24 hours before runtime.
:: Son, im Thirty.... ::
>
Replied 16 May 2002 02:16:07
16 May 2002 02:16:07 Andrew Watson replied:
Just set a varialble equal to that function...
<pre id=code><font face=courier size=2 id=code>
<%
var24HoursAgo = DateAdd("h",-24,Now())
%>
</font id=code></pre id=code>
then filter your recorset for date greater than that variable....
Cheers
Leed
:: Son, im Thirty.... ::
<pre id=code><font face=courier size=2 id=code>
<%
var24HoursAgo = DateAdd("h",-24,Now())
%>
</font id=code></pre id=code>
then filter your recorset for date greater than that variable....
Cheers
Leed
:: Son, im Thirty.... ::