Help with Datediff

J

jake.ibood

Hello,

I need help with the following. I'm not a programmer, but need to fix
one thing. Can soeone tell me what's wrong with the following?

"SELECT * FROM TblEvents WHERE DATEDIFF('d', fldDateArchive, now()) <
0 & DATEDIFF('d', fldDatePublish, now()) > 0 ORDER BY fldDateEvent
ASC"

The idea is to publish only the events where the archive date isn't
due yet and where the publishdate is past (> 0).

Thanks!
 
A

Allen Browne

Perhaps something like this:

SELECT TblEvents*
FROM TblEvents
WHERE ((fldDateArchive >= Date())
AND (publishDate < Date()))
ORDER BY fldDateEvent;

That will require only one call to get today's date for the whole query,
instead of 2 DateDiff() calls for every record.
 
J

jake.ibood

Perhaps something like this:

SELECT TblEvents*
FROM TblEvents
WHERE ((fldDateArchive >= Date())
AND (publishDate < Date()))
ORDER BY fldDateEvent;

That will require only one call to get today's date for the whole query,
instead of 2 DateDiff() calls for every record.

--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users -http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.


news:0eed0dc3-6833-4dd5-baac-023d7a392b39@n77g2000hse.googlegroups.com...
Works like a charm. Thanks!!!
 

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

Similar Threads

Datediff 2
DateDiff function throwing error in Where clause 7
outer join not working 9
DateDiff Select Statement 1
Help with small result type 2
DateDiff calculation 3
Can't query DateDiff 3
datediff problem 3

Top