• John Paul-702936 (7/27/2011)


    - how to get the Last 30 days records from a table in Oracle if the column is in format string -

    like

    Example - the value in the table is - 1251807219

    the value in formatted is "2009-09-01 08:13:39.000"

    and after foramting date I want to use this column in where condition

    to get the records from last third days

    IN SQL SERVER , I can using Date Add - but how cani get the Oracle

    Select col1 from tabel

    where dateadd(s,convert(int,1251807219)-(4*60*60),'01/01/1970') <getdate()- 30

    Please help..

    Is this part of a Data Warehouse?

    If the answer is Yes, check your DIM_DATE dimension table, most probably there is already a 01/01/1970 based number column showing the proper number for every single date. Join against DIM_DATE and filter your 30 days on DIM_DATE.

    _____________________________________
    Pablo (Paul) Berzukov

    Author of Understanding Database Administration available at Amazon and other bookstores.

    Disclaimer: Advice is provided to the best of my knowledge but no implicit or explicit warranties are provided. Since the advisor explicitly encourages testing any and all suggestions on a test non-production environment advisor should not held liable or responsible for any actions taken based on the given advice.