Re: How to search for a date
| From: | John McKerrell | Date: | Thu, 05 Feb 2004 15:59:22 +0000 |
| Subject: | Re: How to search for a date | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-176902@lists.php.net to get a copy of this message | ||
For MySQL you're still going to need NOW() instead of CURRENT_DATE
though surely?
John
On Thu, 2004-02-05 at 15:57, John W. Holmes wrote:
> From: "Brian Dunning" <brian@briandunning.com>
> Subject: [PHP] How to search for a date
>
> A date? Well, you could try Friendster or orkut to find date, or... oh
> wait...
>
> > Sorry this is such a basic question - but I couldn't find it online.
> >
> > I have a date field in MySQL: 0000-00-00. I'm trying to insert or
> > search for the current date, and I can't find the way to state that in
> > the SQL. This is wrong, can someone please tell me what's correct?
> >
> > INSERT INTO mytable (dateField) VALUE (CURRENT_DATE);
> >
> > SELECT * FROM mytable WHERE dateField = CURRENT_DATE;
>
> Sucks how missing one letter will jack things up.
>
> INSERT INTO mytable (dateField) VALUES (CURRENT_DATE);
>
> Missing the S in values. That'll cause you first query to fail which will
> cause your second query to fail since there's no matching row. :)
>
> ---John Holmes...