Re: php - assigning date variables
| From: | Lerp | Date: | Mon, 25 Feb 2002 18:41:43 +0000 |
| Subject: | Re: php - assigning date variables | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-86136@lists.php.net to get a copy of this message | ||
Hi there :)
1. mysql_query("SELECT * FROM table WHERE date ='$mydate'"); # where date
is same
2. mysql_query("SELECT * FROM table WHERE date > '$mydate'"); # where date
is newer
3. mysql_query("SELECT * FROM table WHERE date < '$mydate'"); # where date
is older
4.mysql_query("SELECT * FROM table WHERE date BETWEEN '$myfirstdate' AND
'$myseconddate'"); # where date is between 2 dates
Hope this helps, Joe :)
"Craig Westerman" <westerman@chanuteks.com> wrote in message
news:DEECKMLOFODOLNHCJBFPOEFADKAA.westerman@chanuteks.com...
> $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
>