Solved

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

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

Accepted Solution

by:
Dave Baldwin earned 500 total points
Comment Utility
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
Comment Utility
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

This article will show, step by step, how to integrate R code into a R Sweave document
These days socially coordinated efforts have turned into a critical requirement for enterprises.
Learn the basics of strings in Python: declaration, operations, indices, and slicing. Strings are declared with quotations; for example: s = "string": Strings are immutable.: Strings may be concatenated or multiplied using the addition and multiplic…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now