Friday, July 3, 2020

SQL: INSERT INTO and DATE()?

Dale Mccoun: insert into table_name(date_field)values(to_date('2003/05/03 21:02:44', 'yyyy/mm/dd hh24:mi:ss'));

Sheron Perrez: I haven't used MySQL, but I did a little searching and here is a function that you might be wanting: Now()There is also another function that I found called currdate().

Roselee Mczeal: mysql_query("INSERT INTO sometable (date) VALUES ( DATE("Y-m-d") )");this is the standard date format which is supported by MySQL.

Elden Dedon: Sql Insert Into Date

Clay Lipira: your query should look like this $sql=mysql_query("INSERT INTO sometable(`date`) VALUES (DATE())") or die(mysql_error());Also add some error checking to your query like this $sql="INSERT INTO sometable(`date`) VALUES (DATE())"echo $sql;$query=mysql_query($sql) or die(mysql_error());this will allow you to check for error easily. Email me if you need more help....Show more

Rosalyn Olivera: first, check if your mysql version supports the date() function..The date! function requires parameters, like: DATE(NOW()).You can use CURDATE() instead if you want to store the current date.MySQL query (queried through phpmyadmin)INSERT INTO `DB`.`TABLE` (`date`) VALUES (CURDATE( ))...Show more

No comments:

Post a Comment