select data between date

select data between date

am 04.12.2005 14:52:46 von Diego

Hello.
My name is Diego.
At first, let me say: * I'm trying write in english. =) *


I'm trying to learn php+mysql, but I am stuck in a sentence..

I've :

idBirth - autonumeric
date - date (YYYY-MM-DD)
timestart - time (00:00:00)
timeend - time (00:00:00)

idBirth is that I use to relation with another tables.

My trouble is: I don't know how to select a value between 2 dates. (i.e.
2005-12-04 and 2005-1-15).

I hope that you can help me... ('cuz write this was hard :lol: )

ps: does anybody know a mysql spanish news?

Re: select data between date

am 04.12.2005 15:17:36 von Shion

Diego wrote:
> Hello.
> My name is Diego.
> At first, let me say: * I'm trying write in english. =) *
>
>
> I'm trying to learn php+mysql, but I am stuck in a sentence..
>
> I've :
>
> idBirth - autonumeric
> date - date (YYYY-MM-DD)
> timestart - time (00:00:00)
> timeend - time (00:00:00)
>
> idBirth is that I use to relation with another tables.
>
> My trouble is: I don't know how to select a value between 2 dates. (i.e.
> 2005-12-04 and 2005-1-15).

Should be something like (assuming that date column is of the type DATE):
SELECT * FROM WHERE date <= '2005-12-04' AND date >= '2005-1-15'


> ps: does anybody know a mysql spanish news?

Not really, but if I haven't mixed the languages, I think you can find things
in Spanish at http://www.mysql-hispano.org/


//Aho

Re: select data between date

am 04.12.2005 15:41:25 von Anthony Frost

In message

> idBirth - autonumeric
> date - date (YYYY-MM-DD)
> timestart - time (00:00:00)
> timeend - time (00:00:00)
>
> idBirth is that I use to relation with another tables.
>
> My trouble is: I don't know how to select a value between 2 dates. (i.e.
> 2005-12-04 and 2005-1-15).

First of all, stick to the same date format. Your second date needs to
be 2005-01-15 which then means you can do a simple comparison like...

....WHERE date < '2005-01-15 AND date > '2005-12-04'

....in your SELECT clause.

Anthony

Re: select data between date

am 05.12.2005 12:09:12 von Hilarion

>> Hello.
>> My name is Diego.
>> At first, let me say: * I'm trying write in english. =) *
>>
>>
>> I'm trying to learn php+mysql, but I am stuck in a sentence..
>>
>> I've :
>>
>> idBirth - autonumeric
>> date - date (YYYY-MM-DD)
>> timestart - time (00:00:00)
>> timeend - time (00:00:00)
>>
>> idBirth is that I use to relation with another tables.
>>
>> My trouble is: I don't know how to select a value between 2 dates. (i.e.
>> 2005-12-04 and 2005-1-15).
>
> Should be something like (assuming that date column is of the type DATE):
> SELECT * FROM WHERE date <= '2005-12-04' AND date >= '2005-1-15'


Why not use "BETWEEN" operator? It's just the situation it's for:

SELECT *
FROM
WHERE (date BETWEEN '2005-01-15' AND '2005-12-04')


Hilarion

Re: select data between date

am 06.12.2005 03:48:59 von Diego

thanks!

I'm working in the examples!

Diego