简体   繁体   English

将此SQL Server查询转换为Oracle

[英]Convert this SQL Server query to Oracle

I have the following in a SQL Server query which I have to convert to Oracle sp 我在SQL Server查询中有以下内容,必须将其转换为Oracle sp

DATEADD(dd, 0, DATEDIFF(dd, 0, DATEADD(ss, -L_LAST_TIME, TR.TR_DATETIME))) AS TRDATE,

Essentially you subtract L_LAST_TIME seconds from TR_DATETIME and then truncate the time part and keep only the date part. 基本上你减去L_LAST_TIME从秒TR_DATETIME然后再截断时间部分,只保留日期部分。

You can divide intervals: 您可以划分间隔:

select trunc(TR.TR_DATETIME - interval L_LAST_TIME SECOND) AS TRDATE  

or 要么

select trunc(TR.TR_DATETIME - NUMTODSINTERVAL(L_LAST_TIME, 'SECOND')) AS TRDATE

We can do arithmetic with dates in Oracle. 我们可以在Oracle中对日期进行算术运算。

select trunc(tr.tr_time - (l_last_time/86400)) as trdate
from tr
/

Dividing l_last_time by 86400 turns a number of seconds into a fraction of day. l_last_time除以86400,可以将几秒钟变成一天的一小部分。 Subtracing it from the tr_time column gives you a new, earlier date. tr_time列中对其进行tr_time为您提供一个新的较早的日期。 Truncating a date removes the time component. 截断日期会删除时间部分。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM