简体   繁体   中英

Oracle SQL: condition for a specific date format

I have a date column which usually constists of data + hour + minutes. Sometimes it's just a date. I want to make a condition in where clause, to fetch records only if they have data, hour and minute. How can I do that?

In Oracle, a DATE data type is a binary data type consisting of 7 bytes that represent: century, year-of-century, month, day, hour, minute and second. It ALWAYS has those 7 bytes and it is NEVER stored in any particular (human-readable) format.

Given this, your question does not make sense as you cannot have a DATE data type that does not have hour, minute or second components. If the time components are not provided then default values will be used and set the hours, minutes and/or seconds to 0.

If we rephrase the question to:

I want to make a condition in where clause, to fetch records only if the time component of the date is not midnight. How can I do that?

SELECT *
FROM   table_name
WHERE  date_column > TRUNC(date_column);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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