Forum Moderators: open

Message Too Old, No Replies

Date Functions

         

adammc

11:48 pm on Aug 8, 2007 (gmt 0)

10+ Year Member



Hi guys,

Can anyone please help me with this:

The SQL insert (date functions) didnt work :( All I am getting is the following:

0000-00-00 00:00:00 (instead of correct dates)

[PHP]$query = "INSERT INTO students (

date_reg,
expire_date) VALUES (

NOW()',
'DATE_ADD(NOW(), INTERVAL 12 MONTH')";

$result = @mysql_query ($query);
[/PHP]

phranque

12:48 am on Aug 9, 2007 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



looks like extraneous quotes, mismatched parentheses and missing 'S'.

try this:

INSERT INTO students (date_reg, expire_date) VALUES (NOW(), DATE_ADD(NOW(), INTERVAL 12 MONTHS))

adammc

1:58 am on Aug 9, 2007 (gmt 0)

10+ Year Member



thanks for the reply, i got it sorted using:

[PHP]// format the date & time
$now = time();
$thisYear = date("Y-m-d H:i:s", $now);
$nextYear = date("Y-m-d H:i:s", strtotime("+12 months"));[/PHP]