Datetime as column type : DateTime « Data Type « SQL / MySQL






Datetime as column type

    
mysql>
mysql>
mysql> CREATE TABLE mytable (
    ->     id INT AUTO_INCREMENT,
    ->     begintime DATETIME,
    ->     endtime DATETIME,
    ->     PRIMARY KEY (id)
    -> );
Query OK, 0 rows affected (0.00 sec)

mysql>
mysql> INSERT INTO mytable (begintime, endtime) VALUES
    ->         ('2005-03-27 7:15', '2005-03-27 18:00'),
    ->         ('2005-03-28 8:00', '2005-03-28 18:00'),
    ->         ('2005-03-29 7:30', '2005-03-29 16:50'),
    ->         ('2005-03-30 7:00', '2005-03-30 17:15');
Query OK, 4 rows affected (0.00 sec)
Records: 4  Duplicates: 0  Warnings: 0

mysql>
mysql>
mysql> drop table mytable;
Query OK, 0 rows affected (0.00 sec)

   
    
    
    
  








Related examples in the same category

1.DATETIME: Combination of DATE and TIME in the form '2003-12-31 23:59:59' (8 bytes)
2.Order by DATETIME
3.Produce a time-of-day summary for records
4.You can replace the hyphen (-) and colon (:) characters with any other punctuation character without affecting