I was trying to make a column that stores the showtime of movies.
Since it is more meaningful to have showtimes in the unit of minutes, can I have a date type that has only years to minutes (eg.
2017-12-26 15:30), but no seconds? Thanks!
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It only takes a minute to sign up.Sign up to join this community
There is no special datatype for this :) Instead, you can use DATE_FORMAT
SELECT DATE_FORMAT(now(), '%Y-%m-%d %H:%i');
So you can create a view to converting your datetime column to the specific date format.
create table test (date datetime); insert into test values (now()); select * from test; 2017-12-28 10:30:24
create view v_test as (select DATE_FORMAT(date, '%Y-%m-%d %H:%i')); select * from v_test; 2017-12-28 10:30