从oracle表中检索最新的时间戳值

时间:2013-06-04 18:56:11

标签: oracle

我需要从表中获取最新的时间戳。时间戳值以oracle格式表示。我尝试了以下但没有给出最新时间戳的最新行:

SELECT max(to_char(CAST((FROM_TZ(CAST(GET_UTC_TIMESTAMP(T."Timestamp", TMZDIFF) AS TIMESTAMP),'+00:00') AT TIME ZONE 'US/Eastern') AS DATE),'dd-Mon-yyyy hh24:mi')) as DATETIME FROM DW.KPX_PHYSICAL_MEMORY_DV T where T."Node" like 'server%'

我需要从名为KPX_PHYSICAL_MEMORY_DV的表中获取最新的Timestamp值。知道我怎么这么容易吗?

1 个答案:

答案 0 :(得分:3)

请勿将其投射到char或将其投射到YYYYMMDD而不是dd-Mon-yyyy

SELECT max(CAST((FROM_TZ(CAST(GET_UTC_TIMESTAMP(T."Timestamp", TMZDIFF) AS TIMESTAMP),'+00:00') AT TIME ZONE 'US/Eastern') AS DATE) as DATETIME 
FROM DW.KPX_PHYSICAL_MEMORY_DV T 
where T."Node" like 'server%'