Wednesday, September 4, 2019
Oracle :: essays research papers
Dates in Oracle are stored in numeric format. Each date represents the century, year, month, day, hours, minutes, and seconds. The default date format is DD-MON-YY. Using the SYSDATE function, you can display the current date and time. You can use SYSDATE as you would use any other column name. In order to view the time you will need to use the TO_CHAR function along with a format mask which includes a time format element. For example, you can display the current date by selecting SYSDATE from a table. You usually select SYSDATE from a dummy table called DUAL. All users can access the DUAL table. It is owned by the SYS user. It consists of one column known as DUMMY, and one row with the value X. When you want to return a value - not necessarily a date - once only, the DUAL table is useful. To display the current date using the DUAL table, you use the command shown. And the output displays the current date. Dates are stored as numbers in the database, which enables you to perform arithmetical calculations on them. You can add or subtract a number to or from a date for a resultant date value. You can subtract one date from another to find the number of days between them. You can also add hours to a date and time value. This is performed by dividing the number of hours in the time value by 24. Let's take a look at how you can manipulate dates. Let's say that you want to add and subtract days from the current date. To add one hundred days to the current date, you type the command shown. The result is displayed in the column SYSDATE+100. If you want to subtract 34 days from the current date, you type the command shown. The result is displayed in the column SYSDATE-34. Let's say you want to subtract the hire date from the current date - you type the command shown. The result shows the number of days between the current date and the hire date. Let's say you want to display dates in terms of weeks. To show the number of weeks each employee in department 10 has worked, you first subtract the hiredate from the current date. Then you divide the result by seven. You can use date functions in a similar way to number functions to operate on Oracle dates. The MONTHS_BETWEEN function finds the number of months between two dates. The result is displayed as a numeric value. This is the only date function that does not return a date value.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment