The following articles mainly use the relevant Code to introduce the actual application of Oracle time. I saw the actual application of Oracle time on the relevant website two days ago, if you are interested in the actual operations, you can click to view the following articles.
- select to_char(sysdate,''hh:mi:ss'') TIME from all_objects
Note: the TIME of the first record is the same as that of the last record.
You can create a function to solve this problem.
- create or replace function sys_date return date is
- begin
- return sysdate;
- end;
- select to_char(sys_date,''hh:mi:ss'') from all_objects;
Hours in Oracle time applications
- SELECT EXTRACT(HOUR FROM TIMESTAMP ''2001-02-16 2:38:40'') from offer
- SQL> select sysdate ,to_char(sysdate,''hh'') from dual;
- SYSDATE TO_CHAR(SYSDATE,''HH'')
- 2003-10-13 19:35:21 07
- SQL> select sysdate ,to_char(sysdate,''hh24'') from dual;
- SYSDATE TO_CHAR(SYSDATE,''HH24'')
- 2003-10-13 19:35:21 19
Obtain the year, month, and day.
Processing of year, month, and day in Oracle time applications
- select older_date,
- newer_date,
- years,
- months,
- abs(
- trunc(
- newer_date-
- add_months( older_date,years*12+months )
- )
- ) days
- from ( select
- trunc(months_between( newer_date, older_date )/12) YEARS,
- mod(trunc(months_between( newer_date, older_date )),
- 12 ) MONTHS,
- newer_date,
- older_date
- from ( select hiredate older_date,
- add_months(hiredate,rownum)+rownum newer_date
- from emp )
- )
The above content is an introduction to Oracle time application related projects. I hope you will have some gains.
Article by: http://www.programbbs.com/doc/class10-3.htm