XmisterIS

05-19-2011, 03:07 PM

I am using MySql 5.1 on Debian Lenny

I noticed some weird behaviour in my code, so I investigated.

What it boils down to is this:

let's say there's a table called "abc" which contains a single column, called "whenStored" which is a DATETIME.

let's say there's one row in the table, and whenStored is set to the value 2011-05-18 13:22:13.

Consider the following query:

select now(), whenStored, now()-whenStored from abc;

I get the following three values:

2011-05-19 15:02:40

2011-05-18 13:22:13

1018027.000000

Now it's that last value that has me completely confused ... given that now() here is nearly 26 hours after whenStored, then I would expect the value of now()-whenStored to be: a little less than 26*60*60, which is 93600.

But I'm getting 1018027, which is nearly 283 days!!!

WTF?! :confused::confused::confused:

As you can see I'm a little confused and frustrated ...

Any help gratefully received!

Thanks in advance.

I noticed some weird behaviour in my code, so I investigated.

What it boils down to is this:

let's say there's a table called "abc" which contains a single column, called "whenStored" which is a DATETIME.

let's say there's one row in the table, and whenStored is set to the value 2011-05-18 13:22:13.

Consider the following query:

select now(), whenStored, now()-whenStored from abc;

I get the following three values:

2011-05-19 15:02:40

2011-05-18 13:22:13

1018027.000000

Now it's that last value that has me completely confused ... given that now() here is nearly 26 hours after whenStored, then I would expect the value of now()-whenStored to be: a little less than 26*60*60, which is 93600.

But I'm getting 1018027, which is nearly 283 days!!!

WTF?! :confused::confused::confused:

As you can see I'm a little confused and frustrated ...

Any help gratefully received!

Thanks in advance.