Solved

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

Posted on 2011-02-14
2
370 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
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

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

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

Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
Does the idea of dealing with bits scare or confuse you? Does it seem like a waste of time in an age where we all have terabytes of storage? If so, you're missing out on one of the core tools in every professional programmer's toolbox. Learn how to …
Learn the basics of lists in Python. Lists, as their name suggests, are a means for ordering and storing values. : Lists are declared using brackets; for example: t = [1, 2, 3]: Lists may contain a mix of data types; for example: t = ['string', 1, T…
Learn the basics of if, else, and elif statements in Python 2.7. Use "if" statements to test a specified condition.: The structure of an if statement is as follows: (CODE) Use "else" statements to allow the execution of an alternative, if the …

772 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