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

  • SEARCH
  • Home
  • 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 832187
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T04:19:26+00:00 2026-05-15T04:19:26+00:00

I have generated a dataset that contains data spanning thirty days. Im trying to

  • 0

I have generated a dataset that contains data spanning thirty days. Im trying to issolate new data elements that have appeared in the last 2 days but not in the previous 28 days before that.

  1. I run a PHP script that generates the test data. (PHP and MYSQL return the same time when tested)

  2. I run the following query against it.

  3. Results are returned accuretly for aproximetly half an hour. Then despite the fact I believe there to be matching records none are returned when running this query.

Is there any obvious mistake I’m making in the SQL that would cause this apparent ‘drift’ to occur?

About The Data:

The script generates a ‘race’ per day. It populates the ranking tables with ranking of the 10 ‘jokeys’. For the purposes of testing the script generates races from the previous 2 days with 2 new ‘jokeys’ in the top 10. The remaining 30 days the races are identical.

Results Expected:

The names of two jokeys who have recently ranked in a race (in the last two days and have not ranked in the previous 28).

The SQL:

SELECT *, FROM_UNIXTIME(`race_timestamp`) as ts FROM `rankings`
WHERE `race_venue` = UNHEX(MD5('someplace'))
AND `jokey` IN
  (
SELECT `jokey`
FROM `rankings`
 WHERE `race_timestamp`
BETWEEN # Get results for races between now and two days ago
UNIX_TIMESTAMP(DATE_SUB(NOW(), INTERVAL 2 DAY)) # timestamp two days ago
 AND
UNIX_TIMESTAMP() # time stamp now
   )
AND 
`jokey` NOT IN
(SELECT `jokey`
 FROM `rankings`
 WHERE `race_timestamp`
 BETWEEN  # Get results between 2 and 30 days ago
 UNIX_TIMESTAMP(DATE_SUB(NOW(), INTERVAL 30 DAY)) # time stamp 30 days ago
 AND
 UNIX_TIMESTAMP(DATE_SUB(NOW(), INTERVAL 2 DAY)) # time stamp 2 days ago
 )
GROUP BY jockey;

Hope someone can help! Ben

  • 1 1 Answer
  • 1 View
  • 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-05-15T04:19:27+00:00Added an answer on May 15, 2026 at 4:19 am

    If you want to do this by date, rather than by the exact minute and second, you might change:

    UNIX_TIMESTAMP(DATE_SUB(NOW(), INTERVAL 30 DAY))
    

    to something like:

    DATE(DATE_SUB(NOW(), INTERVAL 30 DAY))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a dataset of around 150 million records that's generated daily it contains:
I have a table that contains a lot of data, where we particularly care
I have a dataset that has an optional last TD that is required to
Hello I am analyzing some data and trying to use a package that contains
I have a strongly-typed dataset that is using DBDirectMethods to insert data into a
I have some designer generated code that I am using to query a dataset.
I have a large data.frame that was generated by a process outside my control,
I'm working with some binary data that I have stored in arbitrarily long arrays
When I have a simple DataSet that has a table with simple column names
I have a data.frame in R. It contains a lot of data : gene

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.