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

  • Home
  • SEARCH
  • 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 6863149
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T02:44:50+00:00 2026-05-27T02:44:50+00:00

I have a MySQL database. All the fields, I assign and I have a

  • 0

I have a MySQL database. All the fields, I assign and I have a datestamp for my date field.
it automatically generates YYYY-MM-DD HH:MM:SS like this 2011-11-21 21:31:37
However, I would like it to do so in two diffrent columns:

A date field with YYYY-MM-DD or 2011-11-21

A time field with HH:MM:SS or 21:31:37

This is my insert php code

$sql= "INSERT INTO  `db`.`table` (`id` ,`fkid` ,`paid` ,`date`)
VALUES (NULL, '$userid', '0', CURRENT_TIMESTAMP);";

I have tried CURRENT_DATESTAMP and it does not work.

The 2nd part of the question is: how to I make the table so it works with the proper code? Should the structure of the of the field be type text, or date?

  • 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-05-27T02:44:50+00:00Added an answer on May 27, 2026 at 2:44 am

    I would not recommend splitting your timestamp into separate date and time columns. Instead, it is easiest to use a DATETIME column, and query it for its date and time portions using the MySQL functions DATE() and TIME():

    SELECT DATE(`date`) AS d, TIME(`date`) AS t FROM db.dable;
    

    When inserting, you can use the NOW() function to set the current timestamp. `CURRENT_TIMESTAMP() is a synonym for NOW().

    $sql= "INSERT INTO  `db`.`table` (`id` ,`fkid` ,`paid` ,`date`)VALUES (NULL ,  '$userid',  '0', NOW());";
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a mysql database charset utf8_general_ci. All fields are utf8_general_ci to. And I
i have downloaded whole database from geonames.org and imported all countries into mysql. i
I have mysql database structure like below: CREATE TABLE test ( id int(11) NOT
I have a MySQL database that has over 9000 rows with 10 fields. It
I have a mysql database table called POST . One of the fields is
So, my problem is this. I have a legacy MySQL database that I'm building
I have a mysql database, I want to select all values that are equal
I have a database (Mysql) with some fields in UTF-8 (I can change that
Scenario: I have a MySQL database of people and all their various features as
Question says all really... I have table in a MySQL database which has a

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.