RE: [PHP] php - assigning date variables
| From: | joakim dot andersson at cybercom dot se | Date: | Tue, 26 Feb 2002 15:50:40 +0000 |
| Subject: | RE: [PHP] php - assigning date variables | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-86262@lists.php.net to get a copy of this message | ||
I think you can't achieve this with the example you've provided.
Perhaps something like this will work:
query = "";
mysql_query("SELECT * FROM table ". $query );
query = "WHERE date = '2001-01-01'"; // This should return all rows with
2001-01-01 as date.
query = "WHERE date > '1995-01-01'"; // All items newer than 1995-01-01.
query = "WHERE date < '1995-01-01'"; // All items older than 1995-01-01.
query = "WHERE date > '1995-01-01' AND date < '1998-01-01'"; //
All items
between 1995-01-01 and 1998-01-01.
Hope this helps
/Joakim
> -----Original Message-----
> From: Craig Westerman [mailto:westerman@chanuteks.com]
> Sent: Monday, February 25, 2002 7:34 PM
> To: php-general@lists.php.net
> Subject: [PHP] php - assigning date variables
>
>
> $query = ""
> mysql_query("SELECT * FROM table WHERE date LIKE '%". $query
> ."%'");
> // returns all items in database
>
>
> $query = "2001-01-01"
> mysql_query("SELECT * FROM table WHERE date LIKE '%". $query
> ."%'");
> // returns all rows that have 2001-01-01 as the date
>
>
> What is proper way to define a variable to include all dates
> newer than
> 1995-01-01?
> $query = "???"
>
> What is proper way to define a variable to include all dates
> older than
> 1995-01-01?
> $query = "???"
>
> What is proper way to define a variable to include all dates between
> 1995-01-01 and 1998-12-31?
> $query = "???"
>
>
> Everything I tried gives me a error. This has to be simple,
> but I must be
> overlooking something. Where would I find the answer?
>
> Thanks
>
> Craig ><>
> westerman@chanuteks.com
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>