![]() |
Date Functions![]() ![]() ![]() ![]() ![]()
One of the ORACLE's more unusual strength is its ability to store and calculate dates, and the number of seconds, minutes, hours, days, months, and years between dates. Date Arithmetic DATE is an ORACLE data type, just as CHAR and NUMBER are, and it has its own unique properties. The DATE data type is stored in a special internal ORACLE format that includes not just the month, day, and year, but also the hour, minute, and second. SQL*PLUS and SQL recognize columns that are of the DATE data type, and understand that instructions from you to do arithmetic with them call for date arithmetic, not regular mathematics. Displaying Dates The usual handling techniques is to assign each date a serial number, which the program uses internally. What you see on the screen is the representation of that number, translated from a form the computer can understand to a form you can understand. When ORACLE makes that transition, it uses the standard format DD MM YY Thus the date looks like this: 27 APR 97. To display the joining date of employee in the standard format, enter. SQL > SELECT ENAME, JOIN_DT FROM EMP 2 WHERE DEPTNO = 2; You can specify a different format for any date column by converting the date
to a char value with the TO CHAR function. The syntax of the TO CHAR function
is TO CHAR(dl,fmt) ADD MONTHS(date,count) adds count months to date GREATEST(datel, date2, date3,...) picks latest date from list of dates LEAST date1, date2, ...) picks earliest date from list of dates LAST DAY(date) gives date of last day of month that date is in MONTHS_BETWEEN(date2, date1) give date2 date1 in months NEXT DAY(date,'day') gives date of next day after date where 'day' is 'Monday', 'Tuesday', and so on. NEW TIME(date,'this "other') gives the date (and time) in this time zone.
This will be replaced by a Time zones are as follows: AST/ADT - Atlantic standard/daylight time BST/BDT - Bering standard/daylight time CST/CDT - Central standard/daylight time ESVEDT - Eastern standard/daylight time GMT - Greenwich mean time HST/HDT - Alaska Hawaii Standard/daylight time MST/MDT - Mountain Standard/daylight time NST - Newfoundland standard time PST/PDT - Pacific standard/daylight time. YST/YDT - Yukon standard/daylight time Round(date,'format') without specified, rounds a date to 12 A.M. Midnight, the beginning of that day) if time of date is before noon, otherwise rounds up to next day. • TRUNC(date,'format') without format specified, sets a date to 12 A.M. midnight, the beginning of that day). TO_CHAR(date,'format') reformats date according to format TO_DATE(striing,'format') converts a string in a given 'format' into an ORACLE date. Will also accept a number instead of string, with certain limits. 'format' is restricted.
|
|
Domain NamesSQL Database Management Systems Relational Database Management System Properties of RDBMS Client Server Computing Oracle Relational Database Database Structure and Space Management SQL Data Types How to Use Data Types? What is Operators and Conditions Character OperatorsOperator Precedence Data Retrieval Using SQL Plus SQL Data Definitions Data Retrieval Using Select SQL Operator Precedence Selecting Rows and Columns The Group by Clause
Having Clause Union, Union all, Intersact and Minus Commands Playing with Numbers Date Functions Example of Date Arithmetic Working with Null Values
Joining Tables and Subqueries Views Synonyms Indexes Clusters Sequences Formatting Query Results with SQL Plus Data Integrity The Optimizer How Oracle Optimizes SQL Statements Evaluating Expression and ConditionsOptimization Hints PL-SQL PL-SQL Architecture Error Reporting Functions Character Functions Composite Data Types PL-SQL Structures How to use PL-SQL Structures Normalization Operator Precedence Cursor Error Handling Database Triggers Types of Triggers Locking Sub Programs Packages New and Improved Data Types Improved Select Statement Advanced Quering Improved Scalability Improved Performance Via Partitioning Object Relational Features Heterogeneous Data Access Improved Security Administration New Data Types Improved Select Statement Changes to the Select Statement Improved Scalability Data Partitioning Oriented Toward Objects Character Functions Creating Object Types Created Nested Tables Oracle8 and Distributed Database Oracle8 Database Management and Security Distributed Database Invoking Export Invoking ImportWeb DesignWeb HostingE Commerce |
| Home | Web Hosting | Web Design | Sitemap |
| Copyright (C) 2007. Web Domain design hosting. All rights reserved. |