函数 返回类型 描述 例子
to_char(timestamp, text) text 把时间戳转换成字串 to_char(current_timestamp, 'HH12:MI:SS')
to_char(interval, text) text 把时间间隔转为字串 to_char(interval '15h 2m 12s', 'HH24:MI:SS')
to_char(int, text) text 把整数转换成字串 to_char(125, '999')
to_char(double precision, text) text 把实数/双精度数转换成字串 to_char(125.8::real, '999D9')
to_char(numeric, text) text 把 numeric 转换成字串 to_char(-125.8, '999D99S')
to_date(text, text) date 把字串转换成日期 to_date('05 Dec 2000', 'DD Mon YYYY')
to_timestamp(text, text) timestamp with time zone 把字串转换成时间戳 to_timestamp('05 Dec 2000', 'DD Mon YYYY')
to_timestamp(double precision) timestamp with time zone 把 UNIX 纪元转换成时间戳 to_timestamp(200120400)
to_number(text, text) numeric 把字串转换成 numeric to_number('12,454.8-', '99G999D9S')

postgresql 相关datetime:

1,date_trunc('month', now())

2,now()-interval '1 month'

1. decode 用 case when a=1 then b else c end
2. 最后一天  to_date(? +'1 mons'::interval,'yyyy-mm') -1
3. 第一天 to_date(?,'yyyy-mm') , date_trunc('month',?)
4.字段别名 加上 as
5.子查询一定要用别名
6.取子树 ,postgresql需人自己写函数,或者用一些有结构特性字段如1.1,1.1.1,1.1.2  来代替

7.trunc(im.createdate) 可改为date_trunc('day',createdate)
  date_trunc 与oracle的trunc很像,还可以
  SELECT date_trunc('hour', TIMESTAMP '2001-02-16 20:38:40');
  Result: 2001-02-16 20:00:00+00

SELECT date_trunc('year', TIMESTAMP '2001-02-16 20:38:40');
  Result: 2001-01-01 00:00:00+00
8.postgres-当日, 带时分秒,now()  oracle- sysdate
9 postgres-当日,不带时分秒current_date,oracle  to_char(sysdate,'YYYY-MM-DD)
10.nvl 全部替换成 coalesce  如 coalesce(im.invoiceamount,0)
11.小数据位数round,例保留一位小数 用select round(2.16,1)  Result: 2.2 会四舍五入
12 转志数据类型用::数据类型,如to_number() 改用::numeric
13. 如果取子树,不包含自身,使用函数时,第二个参数取2,如,getorgantree(?,2)
14.项目树函数第一个参数是id,其他的如果地区编码,税务机关分别有参数为编码的,如get..tree(code,level),参数为id的,如get..treebyid(id,level)
15.修改表时,表名不能带别名,如update taxpayer_cognizance_invoice tc   这里taxpayer_cognizance_invoice 不能带别名tc

postgres时间转换函数的更多相关文章

  1. MySQL 日期、时间转换函数

    MySQL 日期.时间转换函数:date_format(date,format), time_format(time,format) 能够把一个日期/时间转换成各种各样的字符串格式.它是 str_to ...

  2. Mysql日期转换函数、时间转换函数

    Mysql日期转换函数.时间转换函数 一.MySQL 获得当前日期时间 函数 1,获得当前日期+时间(date + time)函数:now(): select now(); 结果: :: 2,获得当前 ...

  3. mysql 时间函数 时间转换函数

    时间函数 Now 获取当前时间 current_timestamp 获取当前时间 localtimestamp 时间转换 UNIX_TIMESTAMP    "2009-09-15 00:0 ...

  4. php中时间转换函数

    date("Y-m-d H:i",$unixtime)  1.php中获得今天零点的时间戳 要获得零点的unix时间戳,可以使用 $todaytime=strtotime(“tod ...

  5. JS 时间转换函数 字符串时间转换毫秒(互转)

    字符串转化为日期 let util = function(){ Date.prototype.Format = function(fmt) { var o = { "M+" : t ...

  6. sql时间转换函数--备忘

    总是忘记 一.语法: CAST (expression AS data_type) 参数说明: expression:任何有效的SQServer表达式. AS:用于分隔两个参数,在AS之前的是要处理的 ...

  7. ORACLE函数之日期时间转换函数

     1.          TO_CHAR 语法:TO_CHAR(X [,format]) 说明:将X按format格式转换成字符串.X是一个日期或者数字.format是一个规定了X採用何种格式转换 ...

  8. js常用时间转换函数

    1.秒转换为时分秒 // 秒转换为时分秒 export function secExchangeMoment(value = 0){ let secondTime = parseInt(value); ...

  9. SQL Server(第二章) 字符串函数、日期时间函数、转换函数

    --1.CONCAT 函数:字符串连接(支持sql server2012 SQL规则 如果与NULL连接返回NILL) SELECT empid,CONCAT(firstname,lastname) ...

随机推荐

  1. 用C++/CLI搭建C++和C#之间的桥梁(一)—— 简介

    C#和C++是非常相似的两种语言,然而我们却常常将其用于两种不同的地方,C#得益于其简洁的语法和丰富的类库,常用来构建业务系统.C++则具有底层API的访问能力和拔尖的执行效率,往往用于访问底层模块和 ...

  2. Time Step Too Small in Multisim

    http://digital.ni.com/public.nsf/allkb/4B99B2CD6C0C3B6A86257205005D58E0 Error: Time Step Too Small i ...

  3. Go语言设计模式实践:组合(Composite)

    关于本系列 这个系列首先是关于Go语言实践的.在项目中实际使用Go语言也有段时间了,一个体会就是不论是官方文档.图书还是网络资料,关于Go语言惯用法(idiom)的介绍都比较少,基本只能靠看标准库源代 ...

  4. 【转载】利用Matlab制作钟表

    静态时钟 hObject=figure; set(hObject,'NumberTitle','off'); set(hObject,'MenuBar','none'); set(hObject,'v ...

  5. springmvc整合slf4j、log4j记录文本日志

    一.配置pom.xml 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 3 ...

  6. 介紹 IIS 8 全新的 HttpPlatformHandler 模組與 ASP.NET 5 Beta8 重大變更

    HttpPlatformHandler 是一個支援 IIS 8 與 IIS 8.5 的原生模組 (native module),主要使用於 Microsoft Azure Websites 網站服務中 ...

  7. Linux进程间通信:管道,信号量,消息队列,信号,共享内存,套接字

    Linux下的进程通信手段基本上是从UNIX平台上的进程通信手段继承而来的.而对UNIX发展做出重大贡献的两大主力AT&T的贝尔实验室及BSD(加州大学伯克利分校的伯克利软件发布中心)在进程间 ...

  8. Java中Action层、Service层、Modle层和Dao层的功能区分

    一.Java中Action层.Service层.Modle层和Dao层的功能区分: 首先,这是现在最基本的分层方式,结合了SSH架构. modle层就是对应的数据库表的实体类.(即domain) Da ...

  9. window yii2 安装插件 报yiisoft/yii2 2.0.x-dev requires ext-mbstring错

    Problem 1 - yiisoft/yii2 2.0.x-dev requires ext-mbstring * -> the requested PHP extens ion mbstri ...

  10. IIS服务器支持.apk文件下载

    随着智能手机的普及,越来越多的人使用手机上网,很多网站也应手机上网的需要推出了网站客户端,.apk文件就是安卓(Android)的应用程序后缀名,默认情况下,使用IIS作为Web服务器的无法下载此文件 ...