filter results to display those older than 'today'?

S

supasnail

I've been going round in circles here trying to get this to work and my
ignorance of ASP is now showing me up.

I want to construct a query string to allow me to filter entries to be
displayed on a web page with respect to the date-entry contained in the
database.

i.e. an archived results page will show all entries where "my_date" is
less than 'todays date'

I have tried to do this by;

Dim strSQL
Dim showdate

showdate = Date

then...

strSQL = "Select * FROM my_database WHERE my_date <" & showdate

Although this does give a result, it has no actual bearing on todays
date and wondered what strinkingly obvious this I'm doing wrong? when I
use > i get all results displayed, when i use < I get none at all.

thanks for any help
 
S

supasnail

I don't know if it makes any difference but I have the database field
set to date/time, and "short Date" and am using a
<%session.lcid=1046%> on the results page ( I know this is really for
Portugal but the 2057 for UK never displays as UK date format should,
not for me anyway.)
The Access database can be written to and read from happily and
displays the date correctly. I just dont seem to be able to work out
how to filter with respect to todays date.

S



An Access
 
B

Bob Barrows [MVP]

supasnail said:
I've been going round in circles here trying to get this to work and
my ignorance of ASP is now showing me up.

I want to construct a query string to allow me to filter entries to be
displayed on a web page with respect to the date-entry contained in
the database.

i.e. an archived results page will show all entries where "my_date" is
less than 'todays date'

I have tried to do this by;

Dim strSQL
Dim showdate

showdate = Date

then...

strSQL = "Select * FROM my_database WHERE my_date <" & showdate

Although this does give a result, it has no actual bearing on todays
date and wondered what strinkingly obvious this I'm doing wrong? when
I use > i get all results displayed, when i use < I get none at all.

thanks for any help
If you want today's date, then use the Date() function:

strSQL = "... WHERE my_date < Date"
 
S

supasnail

Thanks Bob, thats perfect - I was on the right lines but you've allowed
me to put everything in the right place lol. Now,... on to my next
headache lol

thank you very much

S
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top