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 8266009
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T05:00:17+00:00 2026-06-08T05:00:17+00:00

I have an INT (11) column for storing the current timestamp in seconds. The

  • 0

I have an INT (11) column for storing the current timestamp in seconds. The query looks like:

INSERT INTO `abc` (id, timestamp) VALUES ('', UNIX_TIMESTAMP ( NOW () ) )

I don’t know why, but the date isn’t changed. It doesn’t matter when I send the query, the column value isn’t changed. It has 1342692014 value, but I don’t know why.

Is there any option or other function for timestamps? I must store dates in seconds.

  • 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-08T05:00:19+00:00Added an answer on June 8, 2026 at 5:00 am

    You never refer to the timestamp column in your query. You only have a string:

    INSERT INTO `abc` (id, 'timestamp') VALUES ('', UNIX_TIMESTAMP ( NOW () ) )
                           ^^^^^^^^^^^
    

    Edit:

    I get this with your updated code:

    ERROR 1630 (42000): FUNCTION test.NOW does not exist. Check the
    ‘Function Name Parsing and Resolution’ section in the Reference Manual

    Assuming it’s not still the actual code and after fixing the syntax error, I can’t reproduce your results. My educated guess is that id is an auto-incremented integer primary key, your current SQL mode is making MySQL take '' as NULL and inserting a new row… But I haven’t really tested this hypothesis.

    My working code is this:

    CREATE TABLE `abc` (
        `pk` INT(10) NOT NULL AUTO_INCREMENT,
        `id` VARCHAR(10) NULL DEFAULT NULL,
        `timestamp` INT(11) NOT NULL DEFAULT '0',
        PRIMARY KEY (`pk`)
    )
    ENGINE=InnoDB;
    
    INSERT INTO abc (id, timestamp) VALUES ('', UNIX_TIMESTAMP());
    -- Wait a few seconds
    INSERT INTO abc (id, timestamp) VALUES ('', UNIX_TIMESTAMP());
    -- Wait a few seconds
    INSERT INTO abc (id, timestamp) VALUES ('', UNIX_TIMESTAMP());
    
    SELECT timestamp FROM abc WHERE id='';
    

    … and returns this:

    +------------+
    | timestamp  |
    +------------+
    | 1342694445 |
    | 1342694448 |
    | 1342694450 |
    +------------+
    3 rows in set (0.00 sec)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Assume I have a table like this: column A(int) column B(int) 1 2 2
Hi I have written code like this @Id @Column(nullable=false) @GeneratedValue(strategy=GenerationType.AUTO) public int getUserID() {
I have a column of Int Array. I want to add another column to
I have a gridview: A column ( type int ) How can I get
I have one sqlserver 2008 r2 datatable, it has one column autoId int identity(1,1),
I have this table: ID(INT) DATE(DATETIME) Under the DATE column there are a lot
You have a table table1 that contains id column, that is int(11), not null,
I have a simple table with autoincrementing ID's and one text column. id(int), value(nvarchar)
I have a records in my table Test like this my Date column is
I have some innoDbs with only 2 int columns which are foreign keys to

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.