0

Hi There

I do have a form and a little sql query to update the row before do something else.

Problem is in the code below works when I enter the date like that= 01-02-2001 but I need to do it dynamic I know getdate() but it does not work..

include "inc/inc.php";
echo "<pre>";




if($_POST["submitButton"] == "Submit"){
        

$mn=$_POST["textMembership"];
$date = getdate();
//$today  = mktime(0, 0, 0, date("m")  , date("d"), date("Y"));

//$next2year  = mktime(0, 0, 0, date("m"),   date("d"),   date("Y")+2);

 $sql= care_query("
 

UPDATE 
Contact_positions

SET 
finished =  'getdate()',
started = 'getdate()'

WHERE 
contact_number ='$mn'

AND 
address_number= '4'");

 

 

  mssql_close($con);

Do you have any idea?

Thanks

3
Contributors
6
Replies
7
Views
7 Years
Discussion Span
Last Post by kadriirdak
0

Does not work :( It looks like does not recognize this value.
I have this

$day = date("d");
		$month = date("m");
		$year = date("Y");
	
		$validFrom = $day."/".$month."/".$year;											
		$validTo = $day."/".$month."/".($year+2);

and i put this values in different ways such as

SET 
finished  = '".$validTo."',
started  = '".$validFrom."'

But not working ... There should be a way to insert these variables into sql statement but I have no idea yet.

0

If you are using MySQL and the data type of your fields in your table are DATETIME, then what you need to know is that the dates are stored in the following format: yyyy-mm-dd, NOT in mm/dd/yyyy. So try:

$validFrom =date('Y-m-d');
$validTo=date('Y-m-d',strtotime("now +2 years"));

Edited by hielo: n/a

0

You could also use MySQL to figure out the date:
ie. UPDATE Contact_positions SET x=CURDATE(), y=DATE_ADD(CURDATE(),INTERVAL 1 MONTH)

I prefer using database layer for dates, just in case php and mysql times are out of sync

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.