Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8941589
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T11:20:27+00:00 2026-06-15T11:20:27+00:00

I have an issue in updating only date in datetime field type in MYSQL.

  • 0

I have an issue in updating only date in datetime field type in MYSQL.

I am taking the input from the user (dd/mm/yyyy) using PHP and changing only the date using UPDATE mysql statement. But the datetime field show only 0000-00-00 00:00:00.

Below code is only the php file which updates the table after taking the input from php which passes value using XMLHttprequest.

Pl see my code below:

<?php include 'accesscontrol.php'; ?>
<?php
$q4=$_GET["q4"];

$user = $_SESSION['user'];

$date_array = explode( "/", $q4 );
$new = sprintf( '%4d-%02d-%02d', $date_array[2], $date_array[1], $date_array[0] );


$con = mysql_connect("localhost","tst","tst!@#");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("test", $con);

mysql_query("UPDATE INVHDR_edit SET Invdate= concat ('$new', time(Invdate)) WHERE usr='$user'");


if (!mysql_query($sql,$con))
  {
  die('Error: ' . mysql_error());
  }

mysql_close($con);
?>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T11:20:29+00:00Added an answer on June 15, 2026 at 11:20 am

    Try with this query: UPDATE INVHDR_edit SET Invdate='".$new." 00:00:00' WHERE usr='$user'");

    if you need time to append use following.

    $new = $new.date(" H:i:s");
    mysql_query("UPDATE INVHDR_edit SET Invdate='$new' WHERE usr='$user'");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an updating issue with Binding in my ComboBox. I have created a
I have an issue where I'm updating millions of rows in my DB, so
I have an issue of alphabetically sorting the contacts picked from the address book
The project I have been managing has ran into an issue of updating contents
We have a strange issue with running an Facebook IFrame application (using MVC 2).
I have as a result from a dynamic query a table with only one
I have an issue updating the Acl for a Google Document. I want to
I have a serious ongoing issue with Xcode 4. I have been using Xcode
I have an issue with updating the dependency version of dependent sibling projects. My
I currently have an issue when updating a component collection on an entity. It

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.