List:General Discussion« Previous MessageNext Message »
From:Martin Ramsch Date:September 11 1999 6:07am
Subject:Re: daily report
View as plain text  
On Fri, 1999-09-10 19:41:27 -0500, Manuel Coral A. wrote:
> mysql> select code,order_date  from transactions
>     -> where ( order_date="date '+%Y-%d-%m'" );
> Empty set (0.00 sec)
> 
> I am runing over Linux 2.0.34, and from the promp I get
> this:
> 
> seller:~$ date '+%Y-%d-%m'
> 1999-10-09
> 
> How I can use the Linux clock to make this..??

As you've noticed, it is not possible to execute Unix commands from
within the 'mysql' monitor program.  But to get the current date,
there is a better way: use MySQL's date functions!

Example:
- just get the current date: SELECT CURRENT_DATE;
- Or your query from above:
    SELECT code, order_date
    FROM transactions
    WHERE order_date=CURRENT_DATE;


Now to another problem.  You write:
> One of my databases has a table ( transaction table )
> with an order_date field that store the date of every
> transactions from my minivend shopping cart system, this
> look like this.
> +---------+----------------------------+
> | code    | order_date                 |
> +---------+----------------------------+
> | 0000021 | 0000-00-00                 |
> | 000002  | 1999-10-09                 |
> | 0000011 | 1999-10-09                 |
> | 000001  | 1999-10-09                 |
> | 000003  | 99-10-09                   |
> | 0000031 | Friday, September 10, 1999 |
> +---------+----------------------------+
The last two dates don't MySQL's date format, so you will get
problems!  You should change your application in a way, that
only dates properly formatted as YYYY-MM-DD are inserted ...

Regards,
  Martin
-- 
Martin Ramsch <m.ramsch@stripped> <URL: http://home.pages.de/~ramsch/ >
PGP KeyID=0xE8EF4F75 FiPr=52 44 5E F3 B0 B1 38 26  E4 EC 80 58 7B 31 3A D7
Thread
daily reportManuel Coral A.11 Sep
  • Re: daily reportMartin Ramsch11 Sep