On Thu, 26 Aug 2004 11:31:46 -0500, Yong Wang <[EMAIL PROTECTED]> wrote:
> 
>     I have a database which contains date attribute in string format
> (like 2004-08-12). I want to genearte a report based on period time.
> I use the syntax:
> date1 ='2004-08-12'
> date2='2004-08-18'
> SELECT * FROM account WHERE (TO_DAYS(date) >= TODAYS(date1)) and
> (TO_DAYS(date) <= TO_DAYS(date2));

Is "date" the name of your field? Change it, it is a reserved word in SQL.


> The report script complains the condition after WHERE clause. The
> reason I use TO_DAYS is that I want to convert
> string date data into integer for comparison. Can I use TO_DAYS() like
> this way ?


Even if you can, don't: it isn't needed.
Just use a plain BETWEEN predicate without functions:
SELECT *
FROM account
WHERE date BETWEEN date1 AND date2

Jochem

-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to