开发者

Comparing Date/time on Oracle

Currently on my oracle table, I have the following if condition on my procedure

if TO_CHAR(updatetime, 'DD-MON-YYYY HH:MI:SS') != '01-JAN-1900 00:00:01' then

Suppose the value updatetime from oracle table is "01-JAN-1900 12:00:01 AM" , will my if condition be true or false ?

The reason I'm asking is because I am unsure about the format TO_CHAR converts to. Value on the table is in a 12-Hr clock format, wh开发者_开发百科ile the condition compares with a 24-hr format.

This is my first week working with oracle sql..

Thanks !


What @Tony Andrews said, but you probably want to make your to_char convert to 24 hour clock if you're comparing it to a string containing 24 hour clock value. Change HH to HH24 like this:

if TO_CHAR(updatetime, 'DD-MON-YYYY HH24:MI:SS') != '01-JAN-1900 00:00:01' then 


Oracle DATE columns do not hold the date as a formatted string, it is held (internally) as 7 numeric values: century, year, month, day, hour, minute, second. So it doesn't matter what format you use in your TO_CHAR.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜