Code Bank
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsProgrammingCode Bank

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old August 10th, 2004, 04:34 PM
acutair acutair is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Aug 2004
Posts: 1 acutair User rank is Just a Lowly Private (1 - 20 Reputation Level) 
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

Reply With Quote
  #2  
Old August 10th, 2004, 05:57 PM
coinhunter's Avatar
coinhunter coinhunter is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: May 2004
Location: Battle Creek, Michigan
Posts: 352 coinhunter User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 30 sec
Reputation Power: 5
Send a message via Yahoo to coinhunter
Try using BETWEEN cutoff AND date()
Something like:
Quote:
Using MS Access:
sql = "SELECT * FROM positions WHERE datePosted BETWEEN #" & cutoff & "# AND #"&Date&"# SORT BY datePosted DESC"
Quote:
Other Database:
sql = "SELECT * FROM positions WHERE datePosted BETWEEN '" & cutoff & "' AND "&Date&" SORT BY datePosted DESC"
Good Luck!

BTW, how did you implement this: You are here: Home > Resources > Jobs
Are you using some kind of script for this?

Reply With Quote
Reply

Viewing: ASP Free ForumsProgrammingCode Bank > problem using dateAdd


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway
Stay green...Green IT