Add quotes to you date.

SELECT time_period_id FROM time_periods
WHERE '2003-03-14' BETWEEN time_period_start AND time_period_end;

Worked for me.

Roger

-----Original Message-----
From: Cory Hicks [mailto:[EMAIL PROTECTED]
Sent: Friday, March 14, 2003 3:05 PM
To: [EMAIL PROTECTED]
Subject: Finding an ID between two dates


Hey folks!

I am stumped....been reading the online manual, google groups, to no
avail.

I have a very simple table:

time_period_id int(11) NOT NULL auto_increment,
time_period_start date NOT NULL default '0000-00-00',
time_period_end date NOT NULL default '0000-00-00',
PRIMARY KEY  (time_period_id)

I am trying to get the ID that relates to a date falling between the
range of time_period_start(2003-03-01) and time_period_end(2003-03-15):

$sql = SELECT time_period_id FROM time_periods
WHERE 2003-03-14 BETWEEN time_period_start AND time_period_end;

I should get one result form the query, the id, but I get no results.

Advice? Helpful hints always welcome......

Many thanks!

Cory
--
Cory Hicks
Texas Research International, Inc.
[EMAIL PROTECTED]


---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail
<[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php


---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to