How to convert date into timestamp in SQL query

0 votes

I'm attempting to move data from the old table to a new table, however old table dates are of the datetime datatype, whilst new table dates are of the int datatype and accept timestamp values.

How can the old date be changed in a SQL query so that it can be added to a new table as a timestamp?

INSERT INTO `new_table` (`id`, `user_id`, `doctor_id`, `message_id`, `type`, `is_message`, `is_note`, `doctor_initials`, `call_status`, `message`, `date_created`, `date_updated`, `day`)
  SELECT id, usid, drid, message_id, type, is_message, is_note, doctor, kall, message, datein, 123, ziua
  FROM `old_table`;

I need a function to change an old date from a value to a timestamp, such as the function CONVERT INTO TIMESTAMP in the example above (datein) Any assistance would be greatly appreciated.

The new table's date-created field takes UNIX timestamp values like 1540642765.

Aug 19 in Database by Kithuzzz
• 11,640 points
31 views

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.

Related Questions In Database

0 votes
0 answers

Convert timestamp to date in Oracle SQL

How can we convert timestamp to date? READ MORE

Aug 29 in Database by Kithuzzz
• 11,640 points
9 views
0 votes
0 answers
0 votes
1 answer

Convert Date format into DD/MMM/YYYY format in SQL Server

Using convert() and style 106, you can ...READ MORE

answered Feb 23 in Database by Vaani
• 7,020 points
3,931 views
0 votes
0 answers

How to convert java.util.Date to java.sql.Date?

I need a java.sql since I'm trying ...READ MORE

Aug 11 in Database by Kithuzzz
• 11,640 points
55 views
0 votes
0 answers

Convert date from dd-mm-yyyy to yyyy-mm-dd in SQL Server

Given date: DECLARE @Date1 VARCHAR(50) = '30-01-2015' I want ...READ MORE

Aug 18 in Database by Kithuzzz
• 11,640 points
799 views
0 votes
0 answers

How to convert SQL Server's timestamp column to datetime format

Is there a simple way to convert ...READ MORE

Aug 21 in Database by Kithuzzz
• 11,640 points
121 views
0 votes
0 answers

Creating a search form in PHP [duplicate]

I am working on a function where ...READ MORE

Jun 9 in PHP by Kichu
• 19,040 points
26 views
0 votes
0 answers

How to retrieve data from multiple tables using a PHP form?

I want to retrieve data from multiple ...READ MORE

Jun 25 in PHP by narikkadan
• 19,680 points
147 views
0 votes
0 answers

How to delete image form folder and database

With the code below, I'm displaying data ...READ MORE

Jul 26 in PHP by Kithuzzz
• 11,640 points
121 views
0 votes
1 answer

Why is not preferable to use mysql_* functions in PHP?

The reasons are as follows: The MySQL extension: Does ...READ MORE

answered Sep 7, 2018 in Database by DataKing99
• 8,240 points
391 views
webinar REGISTER FOR FREE WEBINAR X
Send OTP
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP