List:General Discussion« Previous MessageNext Message »
From:Roger Davis Date:March 14 2003 9:13pm
Subject:RE: Finding an ID between two dates
View as plain text  
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:chicks@stripped]
Sent: Friday, March 14, 2003 3:05 PM
To: mysql@stripped
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.
chicks@stripped


---------------------------------------------------------------------
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 <mysql-thread134763@stripped>
To unsubscribe, e-mail
<mysql-unsubscribe-rogerd7215=earthlink.net@stripped>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Thread
Finding an ID between two datesCory Hicks14 Mar
  • Re: Finding an ID between two datesIgnatius Reilly14 Mar
  • Re: Finding an ID between two datesStefan Hinz14 Mar
  • RE: Finding an ID between two datesRoger Davis14 Mar