Skip to content

Instantly share code, notes, and snippets.

@jonleighton
Created August 8, 2011 16:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jonleighton/9cff3986c396eecf6374 to your computer and use it in GitHub Desktop.
Save jonleighton/9cff3986c396eecf6374 to your computer and use it in GitHub Desktop.
$ mysql -u root
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 53
Server version: 5.5.14 MySQL Community Server (GPL)
Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> use test;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> create table fuu (time datetime);
Query OK, 0 rows affected (0.02 sec)
mysql> describe fuu;
+-------+----------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+----------+------+-----+---------+-------+
| time | datetime | YES | | NULL | |
+-------+----------+------+-----+---------+-------+
1 row in set (0.00 sec)
mysql> insert into fuu VALUES ("2009-07-11 20:00:00");
Query OK, 1 row affected (0.01 sec)
mysql> insert into fuu VALUES ("2009-07-11 20:00:00 +0100");
Query OK, 1 row affected, 1 warning (0.01 sec)
mysql> insert into fuu VALUES ("2009-07-11T20:00:00+0100");
Query OK, 1 row affected, 1 warning (0.01 sec)
mysql> SELECT * FROM fuu;
+---------------------+
| time |
+---------------------+
| 2009-07-11 20:00:00 |
| 2009-07-11 20:00:00 |
| 2009-07-11 20:00:00 |
+---------------------+
3 rows in set (0.00 sec)
mysql> quit
Bye
$ psql test
psql (9.0.4)
Type "help" for help.
test=# create table fuu (time timestamp);
CREATE TABLE
test=# \d fuu
Table "public.fuu"
Column | Type | Modifiers
--------+-----------------------------+-----------
time | timestamp without time zone |
test=# insert into fuu values ('2009-07-11 20:00');
INSERT 0 1
test=# insert into fuu values ('2009-07-11 20:00 +0100');
INSERT 0 1
test=# insert into fuu values ('2009-07-11T20:00+0100');
INSERT 0 1
test=# select * from fuu;
time
---------------------
2009-07-11 20:00:00
2009-07-11 20:00:00
2009-07-11 20:00:00
(3 rows)
test=# \q
$ sqlite3 /tmp/test.db
SQLite version 3.7.5
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite> create table fuu (time timestamp);
sqlite> .schema fuu
CREATE TABLE fuu (time timestamp);
sqlite> insert into fuu values ('2009-07-11 20:00');
sqlite> insert into fuu values ('2009-07-11 20:00 +0100');
sqlite> insert into fuu values ('2009-07-11T20:00+0100');
sqlite> select * from fuu;
2009-07-11 20:00
2009-07-11 20:00 +0100
2009-07-11T20:00+0100
sqlite> select datetime(time) from fuu;
2009-07-11 20:00:00
sqlite> .quit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment