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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T20:11:46+00:00 2026-06-10T20:11:46+00:00

I have the following trigger which inserts records into Table B whenever Table A

  • 0

I have the following trigger which inserts records into Table B whenever Table A is updated. This works fine however TableA_date is in unix time format and I want to convert it when the trigger inserts the record in Table B.

DELIMITER $$
CREATE TRIGGER MyTrigger
AFTER INSERT
ON TableA
FOR EACH ROW 
BEGIN
    INSERT INTO TableB SET 
    TableB_id = NEW.TableA_id, 
    TableB_date = FROM_UNIXTIME(NEW.TableA_date, '%d/%m/%y %r'),
    TableB_comment = NEW.TableA_comment;
END $$
DELIMITER ;

In my results, instead of “01/01/70 03:00:05 AM” as the converted date I get “5” – I know the format string is correct as I am able to use it in a select statement. Thanks for your help

  • 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-10T20:11:47+00:00Added an answer on June 10, 2026 at 8:11 pm

    You are working too hard. Just leave out the format string entirely. Dates are stored as dates, not a strings.

    In fact, don’t even use the conversion at all! Just directly assign the date column, and MySQL will do any conversion it needs.

    I’m assuming that TableA_date is stored using the timestamp datatype, and that TableB_date is datetime. (Although you may want timestamp for that one too.)

    If you are using other datatypes like int, or char, then fix it. That’s not the correct way to structure a database.


    Just to answer your actual question (instead of telling you the correct way to do it) the date format you want is yyyy-mm-dd hh:mm:ss not what you have.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have following trigger written for my application which gives me this error Msg
I have the following trigger which gets fired when updated becomes Y . I
I have a trigger which executes after a record is inserted into a table.
I have the following trigger on a table that redirects data and includes data
I have created a trigger on a table which holds an audit log. When
hi i have created a trigger which i want to update a table field
I have the following insert trigger, which is essentially writing a duplicate row from
I have the following triggers on my users table which copies the value to
I have the following function that is supposed to trigger anytime one of the
I have the following code being run if an iphone/ipad/ipod is detected: $('.tooltip-trigger').tooltip({offset: [20,

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.