I've been handed a project that deals with time stamps, and I'm getting a really odd result.
The subquery is a copy/paste to a main query, but, I'm getting different results, and the 838 (I'm assuming) hours is what is throwing me off. The query I'm working with is:
I wanted to change it to
I then noticed that the HourDelta returned as ~800 hours instead of the 2800 hours I was working with before the subquery invention.
The purpose of the change was to try and get rid of duplication in the field results. The other way I can do this query as a single query is
I'm of the frame of mind of "If you've done the calculation once, why do it again?" which is why I'm on this particular optimization route, but the time is way off.
So for a formal question, why the difference on a literal/specific/exact time conversion? I don't see any correlation between 2802 and 838, the hours and minutes for 59:59 doesn't even add up, but I suspect that is a clue. I just don't see it.
-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=
NEVER send the boss to do a techs job
Code:
mysql> select * from (select timediff("2014-05-26 14:33:06", "2014-01-29 20:21:24")) a;
+--------------------------------------------------------+
| timediff("2014-05-26 14:33:06", "2014-01-29 20:21:24") |
+--------------------------------------------------------+
| 838:59:59 |
+--------------------------------------------------------+
1 row in set, 1 warning (0.01 sec)
mysql> select timediff("2014-05-26 14:33:06", "2014-01-29 20:21:24");
+--------------------------------------------------------+
| timediff("2014-05-26 14:33:06", "2014-01-29 20:21:24") |
+--------------------------------------------------------+
| 2802:11:42 |
+--------------------------------------------------------+
1 row in set (0.00 sec)
The subquery is a copy/paste to a main query, but, I'm getting different results, and the 838 (I'm assuming) hours is what is throwing me off. The query I'm working with is:
SQL:
select DocumentID, File, Title, Timestamp, ReviewedDate, ModifiedBy, Owner, timediff(Timestamp, ReviewedDate) TimeModifiedDelta from Document
where Timestamp > now() - interval +3 day and Timestamp>ReviewedDate order by Timestamp desc;
I wanted to change it to
SQL:
select *, hour(TimeModifiedDelta) HourDelta from (select DocumentID, File, Title, Timestamp, ReviewedDate, ModifiedBy, Owner, timediff(Timestamp, ReviewedDate) TimeModifiedDelta from Document
where Timestamp > now() - interval +3 day and Timestamp>ReviewedDate order by Timestamp desc) theReults;
I then noticed that the HourDelta returned as ~800 hours instead of the 2800 hours I was working with before the subquery invention.
The purpose of the change was to try and get rid of duplication in the field results. The other way I can do this query as a single query is
SQL:
select DocumentID, File, Title, Timestamp, ReviewedDate, ModifiedBy, Owner, timediff(Timestamp, ReviewedDate) TimeModifiedDelta, hour(timediff(Timestamp, ReviewedDate)) HourDelta from Document
where Timestamp > now() - interval +3 day and Timestamp>ReviewedDate order by Timestamp desc;
I'm of the frame of mind of "If you've done the calculation once, why do it again?" which is why I'm on this particular optimization route, but the time is way off.
So for a formal question, why the difference on a literal/specific/exact time conversion? I don't see any correlation between 2802 and 838, the hours and minutes for 59:59 doesn't even add up, but I suspect that is a clue. I just don't see it.
-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=
NEVER send the boss to do a techs job