By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,985 Members | 2,920 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,985 IT Pros & Developers. It's quick & easy.

Selecting Records between two date fields

P: n/a
Hello!

Hope y'all can help me. I've just started to use Access and just
putting together some simple asp pages for my band's website.

We've got a "latest news" table in our db and I want to create a
"what's on today" page which will select a article where today's date
falls between a field called startDate and the endDate field.

My SQL (from dreamweaver using vbscript) looks like:
"SELECT * FROM news WHERE newsStartDate < #" & date() & "# AND
newsEndDate > #" & date() & "# ORDER BY newsStartDate ASC

Unfortunately, it's not pulling any of the articles out....Grrr!

Any ideas?

Cheers
Tony

Nov 13 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
to*********@yahoo.co.uk wrote in MESSAGE
<11*********************@g49g2000cwa.googlegroups. com> :
Hello!

Hope y'all can help me. I've just started to use Access and just
putting together some simple asp pages for my band's website.

We've got a "latest news" table in our db and I want to create a
"what's on today" page which will select a article where today's date
falls between a field called startDate and the endDate field.

My SQL (from dreamweaver using vbscript) looks like:
"SELECT * FROM news WHERE newsStartDate < #" & date() & "# AND
newsEndDate > #" & date() & "# ORDER BY newsStartDate ASC

Unfortunately, it's not pulling any of the articles out....Grrr!

Any ideas?

Cheers
Tony


I would guess a problem with date formatting - when feeding the Jet
engine
with an SQL string, it needs dates in an unambiguous format.

....newsStartDate < #" & format$(date(),"yyyy-mm-dd") & "# AND...

See http://allenbrowne.com/ser-36.html for more details.

--
Roy-Vidar

Nov 13 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.