tags:

views:

28

answers:

2

I've a announcement table with the structure,

Msgid int,
title varchar(150)
message text
date_from datetime
date_to  datetime

I've want to list all the announcements which will be due today (i.e) announcements of which today's date falls b/w date_from and date_to.

any ideas?

+4  A: 
WHERE NOW() BETWEEN date_from AND date_to
reko_t
Indeed. And that's *usually* (but not necessarily always) more efficient than `WHERE NOW() >= date_from AND NOW() <= date_to`.
Romain
Does BETWEEN include the endpoints of the range?
Brian Hooper
Yep, it does what Romain showed in the first comment.
reko_t
A: 
SELECT title, message
FROM announcements
WHERE NOW() BETWEEN date_from AND date_to
Treffynnon