How 2 selest asterisk mysql table's fields in a certain date

hi to all
dear friends
i wana have a show from some fields of asterisk mysql database (asteriskcdrdb(cdr table)) in a certain date for example from 2013-4-1 till 2013-5-1
as you know asterisk records all calls information in this table like : calldate,src,dst,duration and …
i wana show all calls of one extension like 3004 in a certain date
i want all records that 3004 is in src field and 3004 is in dst field(all dialed and recieved calls)
i use below query:

select calldate, src, dst from cdr where calldate between 2013-4-1 and 2013-5-1 and src = ‘3004’ or dst=‘3004’;

the problem is in the result
results do not belong to that date, acctually it shows all calls that 3004 dialed and recieved from the first day that extension creats till today,
its imporatant for me to show results in a specific date
please help me
and if my query has any problem please correct it
plzzzzzzzzzzz

That’s a mysql question, not an Asterisk one. It will probably depend on whether your schema has an appropriate data type for calldate. Only the ODBC driver, in Asterisk, seems to support that field name, and it looks like it expects some sort of date/time field.

I don’t know what happens when you try to apply the integer range 2008 to 2007 to such a field, but I’m sure it doesn’t do what you want to do.

To be certain, I imagine you will have to use some sort of cast function and give it a string parameter.

If you ask this on a mySQL forum, please don’t use “wana”, or even “wanna”. The correct expression is “would like to”. “wanna” is an internet slang term and “wana” is a misspelling of it.

You may find this article useful: dev.mysql.com/doc/refman/5.6/en/ … erals.html

(Found by googling “mysql date literals”.)

You could try replacing “en” by the two letter code for your language.

you need to use parenthesis in your query between conditions .

SELECT calldate, src, dst FROM cdr WHERE ( calldate BETWEEN 2013-04-01 AND 2013-05-01) AND ( src = ‘3004’ OR dst=‘3004’ );