I have a sql query to obtainrecords for a date range. My query works find byut when I analyzed data, I found that the records are retirved base don GMT timezone value, thus making the restults incorrect.
I get my time from a unix epoch value in database.
SELECT tableA.columnA,tableB.columnB
FROM tableA INNER JOIN tableB ON tableA.aId = tableB.aId
WHERE (to_date('1970-01-01 00:00:00 +10:00','yyyy-MM-dd hh24:mi:ss') + (tableB.epochValue/60/60/24/1000)) > to_date('--FROM_DATE--', 'yyyy-MM-dd hh24:mi:ss')
AND (to_date('1970-01-01 00:00:00 +10:00','yyyy-MM-dd hh24:mi:ss') + (tableB.epochValue/60/60/24/1000)) <= to_date('--TO_DATE--', 'yyyy-MM-dd hh24:mi:ss');
I want to obtain the records based on my timezone which is GMT+10 but this script gets data based on GMT timezone. I was wondering how to pass my timezone to obtain the correct date object
using http://www.epochconverter.com/, I obtained these values my epoch value - 1345079730 GMT: Thu, 16 Aug 2012 01:15:30 GMT Your time zone: Thu Aug 16 2012 11:15:30 GMT+10
My database is - Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit
Found the answer to my question.
apparently, you need to consider the time zone settings when you calculate epoch value as well
Used TO_TIMESTAMP_TZ instead of to_date