PostgreSQL学习篇9.9 日期/时间类型
2016-12-23 17:07
603 查看
时间/日期类型: timestamp[(p)] [without time zone] timestamp[(p)] with time zone:日期和时间,带时区 interval [(p)] :时间间隔 date:只用于日期 time[(p)] [without time zone] :只用于一日内时间 time[(p)] with time zone :只用于一日内时间,带时区 日期输入: postgres=# show datastyle; ERROR: unrecognized configuration parameter "datastyle" postgres=# show datestyle; DateStyle ----------- ISO, MDY (1 row) postgres=# create table testd(col1 date); CREATE TABLE postgres=# insert into testd values(date '12-23-16'); INSERT 0 1 postgres=# select * from testd; col1 ------------ 2016-12-23 (1 row) 如果有日期列,注意datestyle的设置,因为同一个insert,不同的datestyle会有不同的意义: postgres=# show datestyle; DateStyle ----------- ISO, MDY (1 row) postgres=# insert into testd values(date '1-2-2016'); INSERT 0 1 postgres=# set datestyle='DMY'; SET postgres=# insert into testd values(date '1-2-2016'); INSERT 0 1 postgres=# select * from testd; col1 ------------ 2016-12-23 2016-01-02 2016-02-01 (3 rows) postgres=# postgres=# select time '103245'; time ---------- 10:32:45 (1 row) 各个时区缩写所表示意义: postgres=# select * from pg_timezone_abbrevs ; 特殊时间:now :当前事务的开始时间--可以类比Oracle中的sysdate postgres=# select date 'now'; date ------------ 2016-12-06 (1 row) postgres=# select timestamp 'now'; timestamp ---------------------------- 2016-12-06 04:17:01.645177 (1 row) postgres=# select current_time; timetz -------------------- 05:01:51.535537+08 (1 row) postgres=# select current_date; date ------------ 2016-12-06 (1 row) postgres=# select current_timestamp; now ------------------------------- 2016-12-06 05:02:08.058959+08 (1 row)
相关文章推荐
- Postgresql 日期和时间类型
- PL/SQL 日期时间类型函数及运算
- PL/SQL 日期时间类型函数及运算
- 发现一个很全的java处理时间日期类型的类
- 使用.NET Framework中新的日期时间类型
- 深入JavaScript与.NET Framework中的日期时间(3):JavaScript中的Date类型(中)
- C# string格式的日期时间字符串转为DateTime类型的方法
- 字符串转日期时间类型
- oracle中日期类型与unix 时间戳的转换
- SQL语句中使用日期时间类型时应该注意的一点
- 使用.NET Framework中新的日期时间类型 推荐
- MySQL日期和时间类型
- 深入JavaScript与.NET Framework中的日期时间(3):JavaScript中的Date类型(中)
- 深入JavaScript与.NET Framework中的日期时间(2):JavaScript中的Date类型(上)
- SQL Server 2008新的日期时间数据类型
- oracle中日期类型与unix 时间戳的转换
- MySQL - 日期和时间类型概述
- 第五部份 01 深入JavaScript与.NET Framework中的日期时间 JavaScript中的Date类型
- Sql Server 2005 DATETIME和SMALLDATETIME两种日期时间类型的区别
- 使用.NET Framework中新的日期时间类型[转]