
August 10th, 2004, 04:34 PM
|
|
Registered User
|
|
Join Date: Aug 2004
Posts: 1
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
|
problem using dateAdd
i'm putting together a "job posting" thingadoo for work using ASP/vBasic. basically, the page picks the applicable job openings from a database and displays them, newest listings first.
the jobs are listed for a month only, so i needed some way to subtract time from the current date. vBasics's got a function - dateAdd - and you can add days, weeks, hours, years, &c. You use a negative number when you want to "subtract" time.
so here's a snippet, including my query:
- - -
' set a cutoff at today's date minus 1 month
cutoff = dateAdd("m", -1, date())
' construct a query that will display listings that are no more than 1 month old and show newest listings first
sql = "SELECT * FROM positions WHERE datePosted >= '" & cutoff & "' SORT BY datePosted DESC"
- - -
that works fine if either the month or day are below the cutoff threshold: those listings don't display. but if the datePosted is, say,
8/9/1997, it still gets displayed. it's like it's not checking the year.
here's what it looks like:
http://www.uspra.org/resources/jobsPending.asp
this is only a problem around january, i realize, but it's still sorta wacky. does anyone see anything amiss?
any ideas welcome.
- andre
Last edited by acutair : August 10th, 2004 at 04:35 PM.
Reason: incorrect title
|