Searching for date range in PHP

Thanks for the reply RedRum,



I did as you said but when i go to run the code in phpmyadmin it says there is a value missing in the form. Here is the code I used:

Code:
update '4mmchips' set DateNew = str_to_date(Date,"%d/%m/%Y");

Am i doing something stupid!! lol

No problem. You just need to remove the quotes from the table name in your update. I just tested it and it definately works.

Code:
mysql> CREATE TABLE `4mmchips` (`DateNew` date,`Date` varchar(255)) ENGINE=InnoDB DEFAULT CHARSET=latin1;
Query OK, 0 rows affected (0.04 sec)

mysql> insert into 4mmchips set Date = "28/02/2013";
Query OK, 1 row affected (0.01 sec)

mysql> update 4mmchips set DateNew = str_to_date(Date,"%d/%m/%Y");
Query OK, 1 row affected (0.02 sec)
Rows matched: 1  Changed: 1  Warnings: 0

mysql> select * from 4mmchips;
+------------+------------+
| DateNew    | Date       |
+------------+------------+
| 2013-02-28 | 28/02/2013 |
+------------+------------+
1 row in set (0.02 sec)
 
No problem. You just need to remove the quotes from the table name in your update. I just tested it and it definately works.

Thanks, got it working now:)

Plus i was putting the code into the wrong sql query box. I chose the database i was using and clicked on the sql tab along the top but every time i ran the code it would never work.

Then i found a small icon to the left called 'Query Window' and it worked from there:)

Have been tearing my hair out for days lol

Thanks Again RedRum.
 
Back
Top Bottom