Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8398477
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T21:03:55+00:00 2026-06-09T21:03:55+00:00

I have a sql query to obtainrecords for a date range. My query works

  • 0

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

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T21:03:57+00:00Added an answer on June 9, 2026 at 9:03 pm

    Found the answer to my question.

    apparently, you need to consider the time zone settings when you calculate epoch value as well

    1. add 10 hours (10*60*60*1000 milliseconds) to epoch value – epoch current value is in GMT so to make it EST (GMT+10), I added this.
    2. Used TO_TIMESTAMP_TZ instead of to_date

      SELECT tableA.columnA,tableB.columnB 
      FROM tableA INNER JOIN tableB ON  tableA.aId = tableB.aId 
      WHERE (TO_TIMESTAMP_TZ('1970-01-01 00:00:00 +10:00','yyyy-MM-dd hh24:mi:ss TZH:TZM') +    ((tableB.epochValue+(10*60*60*1000))/60/60/24/1000)) >  to_date('##FROM_DATE## +10:00', 'yyyy-MM-dd hh24:mi:ss TZH:TZM') 
      AND (TO_TIMESTAMP_TZ('1970-01-01 00:00:00 +10:00','yyyy-MM-dd hh24:mi:ss TZH:TZM') + ((tableB.epochValue+(10*60*60*1000))/60/60/24/1000)) <= to_date('##TO_DATE## +10:00', 'yyyy-MM-dd hh24:mi:ss TZH:TZM');
      
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this SQL Query that pulls data from 3 tables. I am unable
I have an SQL Query (For SQL Server 2008 R2) that takes a very
I have a SQL query that contains a derieved table. The derived query looks
I have an SQL query that takes these parameters: @SearchFor nvarchar(200) = null ,@SearchInLat
I have a SQL query that does some ranking, like this: SELECT RANK() OVER(PARTITION
I have an SQL query in PostgreSQL that I'd like to translate to Django.
I have an sql query that requires repeating the same SELECT statement a number
i have this sql query (below) and it works great but i need to
I have a SQL query in which I am getting some records. Query is:
I have a sql query in MySQL and I want an expression that matches

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.