List:General Discussion« Previous MessageNext Message »
From:Stefan Hinz Date:March 14 2003 8:30pm
Subject:Re: Finding an ID between two dates
View as plain text  
Cory,

> 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;

SELECT time_period_id FROM time_periods
 WHERE time_period_start >= '2003-03-01'
   AND time_period_end   <= '2003-03-15'
;

should do the job.

Regards,
--
  Stefan Hinz <hinz@stripped>
  iConnect GmbH <http://iConnect.de>
  Heesestr. 6, 12169 Berlin (Germany)
  Telefon: +49 30 7970948-0  Fax: +49 30 7970948-3

[filter fodder: sql, mysql, query]

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