Ticket #99 (closed QA: fixed)
oracle的sysdate转pg的now()的一些过程
| Reported by: | liaojunqiang | Owned by: | |
|---|---|---|---|
| Priority: | trivial | Milestone: | 2012年6.0版本 |
| Component: | 系统相关 | Version: | 6.0 |
| Keywords: | now(),sysdate,数据库迁移 | Cc: | |
| Due Date: | 12/04/2012 |
Description (last modified by liaojunqiang) (diff)
oracle:
select sysdate from dual;
pg:
select now();
oracle:
sysdate - 30/24/60
这个代表现在时间减30分,sysdate - 30/24这个就是30个小时,其他的,你懂的。
pg:
now()::timestamp + '-30 min'
oracle:
to_date(to_char(sysdate,'yyyy-MM-dd'),'yyyy-MM-dd')
pg:
比较笨的方法
to_date(to_char(now(),'yyyy-MM-dd'),'yyyy-MM-dd')
简单直接的方法
current_date
除了这些其他都可以放心的直接替换,这个只是指商城喔。
Attachments
Change History
Changed 14 years ago by liaojunqiang
-
attachment
SQL语句MSSQL.MySQL.Oracle.PostgreSQL不同用法.pdf
added
SQL语句MSSQL.MySQL.Oracle.PostgreSQL不同用法.pdf
comment:2 Changed 14 years ago by chenchongqi
- Keywords now(),sysdate,数据库迁移 added; now() sysdate removed
comment:3 Changed 14 years ago by huangzhong
还有另外一种写法
select * from ent_news where CREATION_DATE > now() - interval '30days' and status in(0,1);
Note: See
TracTickets for help on using
tickets.
![(please configure the [header_logo] section in trac.ini)](http://www1.pconline.com.cn/global/2008/images/jss/m_logo091125.jpg)