Insert String Date as MySQL Date

Use the MySQL STR_TO_DATE function.

$query = "UPDATE vehicles
          SET vin = '$vin',
              title = '$title',
              cost = '$cost',
              year = '$year',
              make = '$make',
              model = '$model',
              dateOfPurchase = STR_TO_DATE('$dateOfPurchase','%m/%d/%Y'),
              bodyNumber = '$bodyNumber',
              transmissionSN = '$transmissionSN',
              engineSN = '$engineSN',
              knownAs = '$knownAs',
              dateOfRemoval = STR_TO_DATE('$dateOfRemoval','%m/%d/%Y'),
              isInFleet = '$isInFleet'
          WHERE tag = '$tag' AND state = '$state'";
$result = mysql_query($query);
Advertisements

About samehramzylabib

See About on https://samehramzylabib.wordpress.com
This entry was posted in Coding, Database and tagged , , , . Bookmark the permalink.