ASP Date/Time Variables

D

dmiller23462

Hey guys,

I'm back again....

I'm trying to put together a search page but what I'm trying to pull
off is only showing the past week's entries....

I've tried declaring "pastweek" as a variable that is actually the
Now() variable....I can't seem to find any syntax help....Basically I
was thinking something along the lines of Now() - 7 days or Now() - 1
week....however I can do that....

I also tried DateAdd("d", -7, pastweek) but I'm not completely sure
how to put that into the SQL statement without returning any
errors....I am missing an operator somewhere in the statement and I'm
getting a bit flustered....I asked our resident SQL statement expert
and he even tried a few things to no avail....

Let me know what YOU would do in the situation...

snippet of my SQL statement follows;
SQLqry = "SELECT * FROM shortage where date <= " & pastweek
 
J

Jeff Cochran

I'm trying to put together a search page but what I'm trying to pull
off is only showing the past week's entries....

I've tried declaring "pastweek" as a variable that is actually the
Now() variable....I can't seem to find any syntax help....Basically I
was thinking something along the lines of Now() - 7 days or Now() - 1
week....however I can do that....

I also tried DateAdd("d", -7, pastweek) but I'm not completely sure
how to put that into the SQL statement without returning any
errors....I am missing an operator somewhere in the statement and I'm
getting a bit flustered....I asked our resident SQL statement expert
and he even tried a few things to no avail....

Let me know what YOU would do in the situation...

snippet of my SQL statement follows;
SQLqry = "SELECT * FROM shortage where date <= " & pastweek

Might start with:

Could I get a little help with dates?
http://www.aspfaq.com/show.asp?id=2040

Jeff
 
D

dmiller23462

I got it working....The correct syntax that has worked for me is as follows;

**start snippet**
SQLqry = "SELECT * FROM shortage WHERE date >= " & "DateAdd('d', -7, Now())"
**stop snippet**
 

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

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,535
Members
45,008
Latest member
obedient dusk

Latest Threads

Top