Date Difference in Oracle 10g

Hi All,
Am having two input parameter,
1. Period Start Date
2. Period End Date
Now i need to find out the difference for the following parameters between those two dates,
1. Monthly Difference (Number of months between two dates)
2. Quaterly Difference (Number of quaters between two dates --> i.e 3 months difference)
3. Weekly Difference (Number of weeks between two dates)
4. Fortnightly Difference (Number of 15 days difference between two dates)
Can anyone please help me out to achieve this?
Thanks in advance.
Regards,
Sakthi.

Oracle has a MONTHS_BETWEEN function. So that answers your first question.
Everything else I would solve with arithmetic:
select start_date
         , end_date
         , months_between(start_date, end_date) as month_diff
         , months_between(start_date, end_date)/3 as quarter_diff
         , (end_date-start_date)/7 as week_diff
         , (end_date-start_date)/15 as fortnight_diff
from your_tableThese will all return fractions, so you may want to use FLOOR() or TRUNC() to return only integers.
Cheers, APC

Similar Messages

  • How we create new data base in oracle 10g express edition

    hello every body.. i student of B tech n new user of oracle so please help me how we creat new data base in oracle 10g express edition

    Hello, Oracle XE can not create more than one instance, the other editions yes, but like other editions XE allows you to create database schemas, schemas logically grouped objects like tables, views, indexes created by a user. By creating an Oracle user is associated with a schema of the same name.
    Using SYS or system accounts for creating user accounts.
    Syntax to create a user:
    create user Your_user
    IDENTIFIED BY password
    default tablespace users;
    grant connect, resources to your_user;
    Edited by: rober584812 on Jun 25, 2010 9:03 PM

  • Important differences between oracle 10g and 11g

    Hi friends, can anyone tell me (pointwise) what are the major (and minor) differences between Oracle 10g and 11g.
    Please point me to some documents if possible.
    Thanks in advance

    The name of the link says it all: "top_features."
    In short it is Oracle's list of what they have for marketing and sales reasons designated "top features."
    It is not intended to be, and is not, a complete list of features. Often the features Oracle does not
    talk about are the most important.
    Let me give you some examples. I have never seen Oracle announce DBMS_XPLAN as a new feature
    yet you should not run an explain plan without it. Neither have I ever seen Oracle announce the new
    NO_DATA_NEEDED predefined exception. I have listed literally hundreds of new features you will not
    find in Oracle's new features docs.
    I did a presentation at OpenWorld this year as part of the unconference titled "New Features in
    Database 11gR2 that Oracle will not announce." It was easy to prepare a one hour presentation with
    little fear of being proved incorrect. As I turned out only one of the features I presented was mentioned
    by Oracle.
    You can find the presentation slides here:
    http://www.morganslibrary.org/pres/oow09_ucnf.pdf

  • Difference btween oracle 10G database & oracle 11G database

    Hi
    i have a web application have 10G database engine, now i will upload it on a host server witch supports oracle 11G database.
    can i export Dump file from my Oracle10g database and import it into oracle 11G database successful.
    what can i do?
    please suggest me
    thank you

    Hi,
    Difference btween oracle 10G database & oracle 11G database Here is a complete list:
    http://www.dba-oracle.com/oracle11g/oracle_11g_new_features.htm
    can i export Dump file from my Oracle10g database and import it into oracle 11G database successful.Yes. Oracle supports backward compatibility . . .
    You mght not, however do it the other way . . .
    Hope this helps . . .
    Donald K. Burleson
    Oracle Press author
    Author of "Oracle Tuning: The Definitive Reference"
    http://www.rampant-books.com/t_oracle_tuning_book.htm
    "Time flies like an arrow; Fruit flies like a banana".

  • Difference between oracle 10g R1 and R2

    hi,
    I would like to know is there are any difference betweeen oracle 10g R1 and R2. I am using forall condition in a select statement. The query is runnign fine in R2 and not in R1.
    Kinldy update.
    Rgds....

    user537350 wrote:
    hi,
    I would like to know is there are any difference betweeen oracle 10g R1 and R2. I am using forall condition in a select statement. The query is runnign fine in R2 and not in R1. One of the differences is that R1 is obsolete and no longer supported.
    Other than that, there are about 2 years of software changes between the .1 of each release. According to http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14261/whatsnew.htm#sthref37 there was some work done in forall in R1, so they probably got it right by R2.
    Can I assume you have an unpatched R1?

  • Differences between Oracle 10G Client ODBC from 10.1.x to 10.2.x (datatype)

    What differences where implemented to Oracle 10G Clients ODBC connectivity drivers between 10G Release 1 and Release 2 concerning datatypes?
    I have an application that performs a qualified read returning a group of records (this is successful) and then performs a delete on each record read. No errors occur on completion of the application. When using release 1, the records are physically removed. Using release 2 a portion of the same group of records are not removed. The key for the table is a numeric field with six decimal places (not my design). My applications C code defines the field as a DOUBLE.

    I certainly agree that something changed. The question is whether it was a change in function or not. With a lot of these sorts of errors, tracking down the "source" of the error involves finding a change in a piece of code that allowed what was always possible to actually occur. That is, you may have two pieces of code that are functionally identical but that end up allowing the sorts of "round off" errors that are always possible when using doubles. The driver might, for example, now be going down a code path where it shifts a number to the right or left rather than dividing or multiplying by 2, which may make this sort of thing more likely. Functionally, given that doubles don't guarantee infinite precision, these operations are identical, but one may be significantly more likely to cause problems.
    Is your application using the ODBC API directly? Or is it going through a higher-level API? If you are going through ODBC directly, you might look to see whether the data types that are being returned by the driver to your code are the same across driver versions.
    Justin

  • Xpath difference between Oracle 10g and Oracle 11g

    All,
    I'm working on moving our existing stored functions from Oracle 10g (10.2.0.4.0) to Oracle 11g (11.2.0.1.0) and so far, everything has worked just fine on Oracle 11g...execpt for one xpath statement.
    The statement below works fine in Oracle 10g (10.2.0.4.0):
    extractValue(inv_dtl_img, '/service//ground/sortKeyCode') AS "srt_key_cd",
    Please note: I need to use the double slash "//" in order to ignore the two different elements in the schema.
    However, in Oracle 11g (11.2.0.1.0), when this statement is executed in the stored function, I get this:
    ERROR at line 1:
    ORA-00932: inconsistent datatypes: expected - got -
    The extractValue command is pulling data out of an XMLType column, and the corresponding XML schema looks like:
    <service>
    <trans>
    <ground>
    <sortKeyCode>
    </sortKeyCode>
    </ground>
    </trans>
    <nontrans>
    <ground minOccurs=0>
    <sortKeyCode>
    </sortKeyCode>
    </ground>
    </nontrans>
    </service>
    Please note: In the XML message, the "trans" and "nontrans" elements are exclusive, so both will never be populated at the same time. A typical XML message would look like this:
    <service><trans><ground><sortKeyCode>3</sortKeyCode></ground></trans></service>
    or this:
    <service><nontrans><ground><sortKeyCode>5</sortKeyCode></ground></nontrans></service>
    In the schema, the sortKeyCode has been defined in both places as "string maxlen=3", so the datatype of that element is exactly the same in both the "trans" and "nontrans" sections of the schema. The only difference in the schema (outside of the trans and nontrans tags) is the fact that the second "ground" tag is defined with a "minOccurs=0". Could Oracle 11g be treating the schema differently than Oracle 10g, resulting in the error?
    Any thoughts would be appreciated.

    The only way to get an quick answer to that one is to file a service request with Oracle support. It could be a bug or a correct change regarding W3C behavior. Despite this, you moving to 11.2, the extract/extractvalue etc propriety Oracle solutions are deprecated from 11.2 and onwards. The more sensible way to move forward, although, I know more work intensive, is to apply the XQuery alternatives like xmlexist, xquery or xmltable functions.
    Moving to EXTRACT is a bad idea, because this alway will be treated as an XML fragment. If you unlucky then Oracle will deal with this in memory via DOM (the standard solution regarding XML parsing if every smart thing within Oracle can not be applied) and this will result in a performance downgrade due to high CPU and Memory consumption/overhead...
    Your pick...

  • What are the major differences between oracle 10g and oracle express 10g

    Hi
    Can anyone tell, What are the major differences between[b] oracle 10g and oracle express 10g.
    Or if you know any URL, then please do let me know.
    Advance Thanks
    JC

    Dear sir,
    here it is.
    http://www.oracle.com/database/product_editions.html

  • Date format in Oracle 10g XE

    I'm using Oracle 10g XE on Windows Vista and I'm curious as to what determines the date format.
    According to the globalization section in the Oracle installation guide the NLS_DATE format is dependent on the NLS_LANGUAGE setting. In my database the NLS_LANGUAGE is American, the NLS_TERITORY is America and all other NLS_* parameters are blank (default).
    From that I would expect the default date format to be mon-dd-yyyy.
    However when I run SELECT sysdate FROM dual the date is reported as dd/mm/yyyy and this was the default format when I used SQL Developer and when I used the command line SQL*Plus. Obviously something else is determining the date format, but what?

    Your settings are dependent on NLS_LANG on the client.
    They are derived from (assuming Windows) the regional settings of the O/S.
    This means in Western Europe the default 'American_America.WE8MSWIN1252'.
    This makes the default NLS_DATE_FORMAT dd-mm-yy.
    You can override this in the registry, or set up an after logon trigger.
    Sybrand Bakker
    Senior Oracle DBA

  • Looking for a Web Interface for Editing Data in an Oracle 10g Database

    Greetings all!
    My organization is implementing Oracle 10g Release 2 Enterprise version. We have an employee who will need to edit data in the database which will hold staff phone numbers, email addresses, and other contact information. This employee will never need to administer the database or develop tables, queries, etc. They will only need to add and remove rows of data and edit text values stored in a database table.
    Does Oracle 10g have a built-in, browser-based tool that can be used to edit data in a table via a friendly user interface? If no, can you please recommend an easy to use tool for editing data in an Oracle database?
    Thanks for any help you can provide!
    Rachel

    Justin,
    Thanks very much for the tip!
    Do you know if Oracle 10g has any kind of built-in tool for editing data? I have heard of "The Vault", but that appears to be a tool for administering database users, reports, etc. I am looking for some kind of tool that shows the data in a grid layout (like Microsoft Excel) and allows someone to edit and save data in that grid. A web-based tool would be best, but a desktop tool (especially if it's already part of Oracle 10g) would also be good.
    Thanks again,
    Rachel

  • Migrate existing data base to oracle 10g and cluster it

    hi
    we are currently using sql server 2000 and due to some servere dead locks in the application and due to some load issues we wanted to migrate it to oracle 10g.
    At the same time we wanted to have clustered environment in the same server
    That is windows server.
    Can any one suggest how migration can be done..easily ie..by oracle migration work bench or what...
    At the same time can any one suggest how to cluster data base in windows server
    Thanks
    vkumar

    This is re-engineering from one database platform to another.
    You will have to take into consideration several aspects of your application, from SQL comptability to the application performance (SQL) in the Oracle environment.
    There is no magic to this puzzle, the amount of task involved in moving from one database to another depends on complixity of the application and how many database operations will have to be changed. I would suggest /recommend that you should start with a POC on a specific module /area (probably the most complex) of your application and this should give you some idea in the efforts of doing so.

  • Oracle Data Provider for Oracle 10g

    We have an application certified on the ODP 9.2.0.2102, Oracle Client and Oracle ODBC 9.2.0.6. We have a client who is moving to Oracle 10g client within the next few months but will still be hitting an Oracle 9.2 backend.
    My question is: Is the 9.2.0.2102 ODP compatible with the 10g client, or do we need to certify against a newer version of the ODP? And if the latter, what version of ODP is recommended?
    We plan to certify against the latest of both this year, but for now, we need the path of least resistence.
    Thanks for your help.
    Todd

    It is not "hard" to create your own geocoding schema though you will need to know how to create tables (with Oracle Spatial columns) in Oracle and before you do create the tables you should read through the documentation to be certain you have all of the required data and metadata.
    Navteq, a data provider, also has sample geocoding data (http://www.oracle.com/technology/products/spatial/htdocs/spatial_partners_data.html) as well as data for sale. Downloading and importing the Navteq data might give you a good idea about what you will need to do if you were to build your own geocoding schema using your data.
    I hope this helps.
    -Justin

  • Difference between Oracle 10g 64 bit /Oracle 10g 32 Bit Windows

    Hi all
    We are using 10g Oracle 32 Bit windows as well as Oracle 10g 64 Windows at some installations.
    Now we tested these two systems in our office for Testing purpose on two similar machines i.e
    Intel i3 with 4 GB RAM. Database size approx 4GB
    We had the feeling that :-
    a) Oracle datafile Filesize limitation may be there in 32 Bit system but we saw that physically around 3.5 GB datafile size
    is created in 32 Bit windows also
    b) Data Fetching Speed -.We thought that data fetching speed would be higher in 64 Bit machine. But we proved to
    be wrong. Our sample data had approx 7 Millions records (based on Client Live data for 3 years) total in around 20 transaction tables. Further there were other additional 100-150 tables but very smaller ones just master tables
    We used the same client end machine and same Front end and same queries on both servers. To our surpriise - We got the almost similar results in terms of data fetching time in both the 32 Bit as well as 64 Bit windows with similar Oracle 10g 32 bit and Oracle 64 Bit respectively
    Further we find that Anti Virus Programme which may be any say Symatentic or other - troubles much more in Windows 64 Bit environment as compared to Windows 32 Bit environment from settings point of view.
    Kindly advise as to
    a) Whether our above observations are correct
    b) Now under what situations should we use Oracle 10g 64 Windows as compared to Oracle 10g 32 Bit windows
    Regards
    Suresh Bansal

    Hi Suresh;
    Pelase check below link which could give you idea about your issue:
    Comparison of 32-bit and 64-bit Oracle Database on windows
    http://www.dell.com/downloads/global/solutions/oracle_performance_em64t_6850.pdf
    Regard
    Helios

  • Gis data uploading in oracle 10g database

    hello everybody ,
    i am new to oracle 10g ,but i am working in gis field for sometime now.i wanted to know whether there is any method present to upload a gis (shape file)data,and the erdas imagine data, in oracle spatial without going to buy the hefty ,arc sde license.
    thanks in adavance,
    vipul soni

    They are permitted.
    Pproperly designed 'cartridges' use the published Oracle spec. If they live within the restrictions of XE (size, CPU, and no Java stored procedures) they should work.
    Oracle Locator is an example of a properly designed cartridge. So is intermedia.
    Locator does not have any Java SPs and works in XE.
    intermedia does use Java SPs and does not work in XE.

  • How to maintain Data availability in Oracle 10g RAC when LOADING the data?

    Hi
    we are having Oracle 10g server on Sun Solaris(64 bit) with 8 GB RAM.
    We are in need of moving the database to "Oracle 10g RAC". (Real Application Clusters)
    Our doubt is when loading the data into RAC server, will it affect the application?
    coz' we heared that RAC server should be down when we load the data.
    Is this correct?
    If yes, then How to maintain High data availability when we load the data in RAC server?? Please help me.
    Thanks.

    First, is this the same question that a colleague of yours posted in this thread?
    Data Load in RAC
    Second, are other sessions querying the table that you're loading data into? If so, how are you loading the data?
    Justin
    Distributed Database Consulting, Inc.
    http://www.ddbcinc.com/askDDBC

Maybe you are looking for