If you need the date like, '2004/01/01', then shouldn't it be '%Y/%m/%d'?

You still ahve the dashes (the '-' character) in your date-format, and you
need a forward-slash (the '/' character) instead.

Here's what I ran on MySQL:

mysql> select date_format(NOW(), '%Y/%m/%d');
+--------------------------------+
| date_format(NOW(), '%Y/%m/%d') |
+--------------------------------+
| 2004/02/20                     |
+--------------------------------+
1 row in set (0.00 sec)


David
----- Original Message -----
From: "Jacque Scott" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Friday, February 20, 2004 10:31 AM
Subject: Date_Format


> I have the following query where the user will put in a date.  They will
> put it in like '01/01/04'.  I use this date in my WHERE clause but MySQL
> needs the date like '2004/01/01'.  I tried using Date_Format('04/01/01',
> '%Y-%m-%d') to change the way it is formatted but I don't get the
> correct data back.  Can someone help with this?
>
> SELECT DISTINCTROW Products.NSIPartNumber, Sum(tblInvTransaction.Qty)
> AS SumOfQty
> FROM tblInvTransaction INNER JOIN Products ON
> tblInvTransaction.ProductID = Products.ProductId
> WHERE tblInvTransaction.Date <= Date_Format('01/01/04', '%Y-%m-%d')
> GROUP BY Products.NSIPartNumber
> HAVING Sum(tblInvTransaction.Qty)>0;
>

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

Reply via email to