Hi,

  Using PHP? If so, this works quite nicely if you pass your dates as unix
timestamps:

SELECT * FROM table WHERE (FROM_UNIXTIME($theMaxTime) > col AND
FROM_UNIXTIME($theMinTime) < col)

  In other words, "col" needs to be between $theMinTime and $theMaxTime as
in $theMinTime < col < $theMaxTime. Is that what you need? It works the same
way if you don't use timestamps, by the way. timestamps are just more
convenient ;)

-----------------------
Alain Fontaine
Consultant & Developer
VAlain S.A.
Tél: +32-4-2522950
-----------------------

-----Original Message-----
From: Victoria Reznichenko [mailto:[EMAIL PROTECTED]]
Sent: Thursday, February 07, 2002 2:08 PM
To: [EMAIL PROTECTED]
Subject: Extracting fields from a table


Claire,

Thursday, February 07, 2002, 12:35:07 AM, you wrote:

CF> I want to select all entries in my table that in a column with given
CF> dates findes all dates   inbetween $from_date - $to_date. (These are
CF> vars that the user supplies from the HTML-page). I don't know how to set
CF> up the SELECT query. I tried the following way but it didn't work:

CF> SELECT * FROM table WHERE (col=$from_date - col=$to_date)

CF> What is the correct way?

You can use TO_DAYS() function, look at:
    http://www.mysql.com/doc/D/a/Date_and_time_functions.html

You can refer to:
    http://www.mysql.com/doc/C/o/Comparison_Operators.html




--
For technical support contracts, goto https://order.mysql.com/
This email is sponsored by Ensita.net http://www.ensita.net/
   __  ___     ___ ____  __
  /  |/  /_ __/ __/ __ \/ /    Victoria Reznichenko
 / /|_/ / // /\ \/ /_/ / /__   [EMAIL PROTECTED]
/_/  /_/\_, /___/\___\_\___/   MySQL AB / Ensita.net
       <___/   www.mysql.com




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