Answer the question
In order to leave comments, you need to log in
How to write timestamp to database (PostgreSQL)?
Hello!
The database has a last_date column with a timestamp type. It must contain the date and time, respectively.
I tried to insert in various ways, but nothing comes out. Only the year-month-day is updated, and everything else is zero-based.
Answer the question
In order to leave comments, you need to log in
If you have an `updated_at` field in your table, then use it, if not, then add it using this migration:
class AddTimestampsToUser < ActiveRecord::Migration
def change_table
add_column(:users, :created_at, :datetime)
add_column(:users, :updated_at, :datetime)
end
end
INSERT INTO t1
(timestamp_column)
VALUES
(TIMESTAMP '2015-12-03 21:54:38');
So you haven't tried it?'2015-12-03 12:30:00.000000'::timestamp
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question