Ticket #99 (closed QA: fixed)

Opened 14 years ago

Last modified 14 years ago

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

SQL语句MSSQL.MySQL.Oracle.PostgreSQL不同用法.pdf Download (89.6 KB) - added by liaojunqiang 14 years ago.
SQL语句MSSQL.MySQL.Oracle.PostgreSQL不同用法.pdf

Change History

comment:1 Changed 14 years ago by liaojunqiang

  • Description modified (diff)

Changed 14 years ago by liaojunqiang

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);

comment:4 Changed 14 years ago by chenchongqi

  • Status changed from new to closed
  • Resolution set to fixed

comment:5 Changed 14 years ago by liaojunqiang

TIMESTAMP value containing the year, month, day, hour, minute, second

Note: See TracTickets for help on using tickets.