Solved

How do you compare two unix date mysql columns in a query?

Posted on 2011-02-14
2
373 Views
Last Modified: 2012-05-11
I have my query set that displays the columns/data that i want from multiple tables

two of the columns that are displayed are

"test_time"  and "test_time2"

those time columns are in UNIX time

now i would like to compare those two columns... test_time is always going to be older in time than test_time2.

two requests:

have a column added to the query that displays the time difference.

Then i would like to display or get a row count of how many of those comparisons are with in 24 hour difference.

for an added extra bonus.. how can i display a percentage of those are within 24 hours.

Any help would be awesome!! i love EE!!
0
Comment
Question by:jporter80
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 83

Accepted Solution

by:
Dave Baldwin earned 500 total points
ID: 34890594
The number of seconds in 24 hours is 86400.  You can check to see if the difference is less than that and/or you can keep a count of the total and a count of the ones that are less than 86400.  Then divide the 'less' total by the overall total and multiply by 100 to get the percentage.
0
 

Author Comment

by:jporter80
ID: 34890790
i think i figure out now how to get the percentage and count... now i just need help adding/creating a column to the query called "time_diff" and display the time difference of the other two columns.

0

Featured Post

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
MySQL recovery 7 33
Understanding ping command in Ubuntu 5 33
restriction of entering a a page 5 34
How do I speed up this PDO query 4 15
This article discusses how to create an extensible mechanism for linked drop downs.
Many old projects have bad code, but the budget doesn't exist to rewrite the codebase. You can update this code to be safer by introducing contemporary input validation, sanitation, and safer database queries.
Learn the basics of while and for loops in Python.  while loops are used for testing while, or until, a condition is met: The structure of a while loop is as follows:     while <condition>:         do something         repeate: The break statement m…
The viewer will learn how to count occurrences of each item in an array.

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question