Re: SQL Date guru in the house?
| From: | Petar Nedyalkov | Date: | Wed, 11 May 2005 08:12:04 +0000 |
| Subject: | Re: SQL Date guru in the house? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-214911@lists.php.net to get a copy of this message | ||
On Wednesday 11 May 2005 09:17, mwestern@sola.com.au wrote:
> Hi All,
>
> I have a small problem.
>
> I have a project in which someone has got three integer fields for
> holding the date. DD, MM, YYYY in an sql database. I now have to
> have a page that inputs two dates and select records between those two
> dates.
>
> If I had a date field in the table it would be fairly simple, but I'm
> hoping to do this search/comparison without having to rewrite the
> pages/database that has already been designed.
>
>
> Start Date: 11/05/2005
> End Date: 11/04/2005
> SELECT * FROM blah WHERE mm BETWEEN 04 AND 05 AND dd BETWEEN 11 AND 11
> AND yyyy BETWEEN 2005 AND 2005
>
> Doesn't work for obvious reasons. Is there any way that I can do
> this date comparison I the SQL statement without having a decent date
> field?
Yes there's a way ;-)
But you've mixed the month and day in the query.
The standart textual format is MM/DD/YYYY :-)
SELECT * FROM blah WHERE mm BETWEEN 11 AND 11 AND dd BETWEEN 4 AND 5 AND yyyy
BETWEEN 2005 AND 2005
> My apologies as this is australian date format and this list is in the
> US I think?
> Regards
> Matthew
--
Cyberly yours,
Petar Nedyalkov
Devoted Orbitel Fan :-)
PGP ID: 7AE45436
PGP Public Key: http://bu.orbitel.bg/pgp/bu.asc
PGP Fingerprint: 7923 8D52 B145 02E8 6F63 8BDA 2D3F 7C0B 7AE4 5436
Attachment: [application/pgp-signature]
Attachment: [application/pgp-signature]