transforming date into parts

  • hi all,

    i am using the following code to transform date from a source column in the form '01-jan-03' into day,month,quarter,year

    SELECT DATEPART(yyyy, INDEX_DAT) AS TheYear,

    'Q'+CAST(DATEPART(qq, INDEX_DAT) as varchar) AS TheQuarter,

    DATEPART(mm, INDEX_DAT) AS monthnumber,

    DATENAME(month, GETDATE()) AS 'Month Name',

    DATEPART(dd, INDEX_DAT) AS TheDay

    FROM [lse101index]

    the above code was working perfectly ok when i had a SQL server database as the source but when i use oracle as the datasource i do not get the proper result instead i get the problem datepart invalid identifier.how can i solve this problem so that when i have a source column from an oracle database into the form day,month,quarter and year.

    i would be vey grateful if some one is able to help me with this.i am in dire need for help for my project

  • I guess you need to replace the DATEPART function (MSSQL function ) with an equivalent function in ORACLE.

    Relationships are like Banks.You Invest the Principal and then get the Interest.


    He who knows others is learned but the wise one is one who knows himself.

  • hi all,

    can anyone tell me what is equivalent to

    DATEPART function ORACLE.So that i can split the date column into date,week,quarter and year..

  • This might help u

    http://www.schemamania.org/jkl/booksonline/SQLBOL70/html/2_005_33.htm

    Relationships are like Banks.You Invest the Principal and then get the Interest.


    He who knows others is learned but the wise one is one who knows himself.

  • can i have a sample code to split date into parts in oracle as i have tried doing it but it doesnt seem to work.i am new into using sql.so i would be very grateful thankyou

  • hi all,

    i am using the following code to transform date from a source column in the form '01-jan-03' into day,month,quarter,year

    SELECT DATEPART(yyyy, INDEX_DAT) AS TheYear,

    'Q'+CAST(DATEPART(qq, INDEX_DAT) as varchar) AS TheQuarter,

    DATEPART(mm, INDEX_DAT) AS monthnumber,

    DATENAME(month, GETDATE()) AS 'Month Name',

    DATEPART(dd, INDEX_DAT) AS TheDay

    FROM [lse101index]

    the equivalent code i am using for oracle source is

    select TO_Char(index_date,'fmMONTH') as MONTH,TO_NUMBER(index_date,'fmmyyyy')as year from tableindex;

    but i am still having the problem invalid identifier MONTH

    i am using the above code to split a date column from an oracle DB as source in the form '01-jan-03' into month and year .what should i do about this any suggestions or sample code plz..if anyone can help

Viewing 6 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic. Login to reply