ORACLE Convert the long millisecond into Date
Asked Answered
H

1

1

I have a Field in ORACLE as CREATED (NUMBER). It stores the time in MILLISECONDS or you can say long format. Now the requirement is to find the data between two dates using the Field CREATED.

I have the following below query which is working for where condition, but not for between condition:

SELECT date'1970-01-01' + TIMECREATED / 1000 / 60 / 60 / 24 as timet 
FROM XXX_TABLE WHERE ITBD='829993';

Can someone provide me the SQL to get the data between two dates?

Hesperides answered 28/2, 2012 at 14:11 Comment(2)
Please can you show us the code that is not working?Kelby
... and explain in what way it fails to work?Belated
I
1

Playing with Oracle Date literals, timestamps and day-to-second intervals:

You can try something of this kind:

select *
  from the_table where to_timestamp(the_date_column,'DD/MM/YYYY') - date'1970-01-01'
                 between numtodsinterval(first_created/1000,'second') and numtodsinterval(second_created/1000,'second')

or

select *
  from the_table
 where date'1970-01-01' + numtodsinterval(created/1000,'second')
       between to_timestamp('2011-01-01','YYYY-MM-DD')
           and to_timestamp('2012-01-01','YYYY-MM-DD')
Impose answered 28/2, 2012 at 14:43 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.