select timestamp + 0
Hi, i'm using the 4.1.10 version of mysql. If I do : select max(timestamp + 0 ) as timestamp from news; ++ | timestamp | ++ | 20050314194920 | ++ so i got the full timestamp(14), but if I do : select max(timestamp) + 0 as timestamp from news; +---+ | timestamp | +---+ | 2005 | +---+ Did i miss something in the documentation ? or is it normal ? thanks -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Re: select timestamp + 0
Mister Jack wrote: Hi, i'm using the 4.1.10 version of mysql. If I do : select max(timestamp + 0 ) as timestamp from news; ++ | timestamp | ++ | 20050314194920 | ++ so i got the full timestamp(14), but if I do : select max(timestamp) + 0 as timestamp from news; +---+ | timestamp | +---+ | 2005 | +---+ Did i miss something in the documentation ? or is it normal ? thanks What does select max(timestamp) as timestamp from news; return? What would you get if that string was converted to a number? -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Re: select timestamp + 0
It returns : select max(timestamp) as timestamp from news; +-+ | timestamp | +-+ | 2005-03-14 19:49:20 | +-+ and also : select timestamp as timestamp from news limit 1; +-+ | timestamp | +-+ | 2002-03-25 19:45:32 | +-+ so If I do : select timestamp + 0 as timestamp from news limit 1; ++ | timestamp | ++ | 20020325194532 | ++ So i would expect a max(timestamp) + 0 to work the same than without the max. is this a bug ? (the code rely heavily on a result as a timestamp(14), like MMDDHHmmss, so getting this work helps migrating from 4.0 to 4.1) thanks for your help On Wed, 16 Mar 2005 14:36:42 -0600, gerald_clark [EMAIL PROTECTED] wrote: Mister Jack wrote: Hi, i'm using the 4.1.10 version of mysql. If I do : select max(timestamp + 0 ) as timestamp from news; ++ | timestamp | ++ | 20050314194920 | ++ so i got the full timestamp(14), but if I do : select max(timestamp) + 0 as timestamp from news; +---+ | timestamp | +---+ | 2005 | +---+ Did i miss something in the documentation ? or is it normal ? thanks What does select max(timestamp) as timestamp from news; return? What would you get if that string was converted to a number? -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Re: select timestamp + 0
Mister Jack wrote: It returns : select max(timestamp) as timestamp from news; +-+ | timestamp | +-+ | 2005-03-14 19:49:20 | +-+ The string shown above converted into a number is 2005. ( Unless you think ist should be 1988 ) Add 0, and it is still 2005. and also : select timestamp as timestamp from news limit 1; +-+ | timestamp | +-+ | 2002-03-25 19:45:32 | +-+ so If I do : select timestamp + 0 as timestamp from news limit 1; ++ | timestamp | ++ | 20020325194532 | ++ So i would expect a max(timestamp) + 0 to work the same than without the max. is this a bug ? (the code rely heavily on a result as a timestamp(14), like MMDDHHmmss, so getting this work helps migrating from 4.0 to 4.1) thanks for your help -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Re: select timestamp + 0
From the manual : MIN() and MAX() may take a string argument; in such cases they return the minimum or maximum string value. so I understand that for a timestamp column, values are converted and then compared as strings, then the function return a string, so adding + 0 convert it to a number (which is different from adding 0 to a timestamp). MIN/MAX operating on timestamp would have been more straightforward, no ? Or is there anything to coerce a string into a timestamp ? (appart a format ) On Wed, 16 Mar 2005 15:40:26 -0600, gerald_clark [EMAIL PROTECTED] wrote: Mister Jack wrote: It returns : select max(timestamp) as timestamp from news; +-+ | timestamp | +-+ | 2005-03-14 19:49:20 | +-+ The string shown above converted into a number is 2005. ( Unless you think ist should be 1988 ) Add 0, and it is still 2005. and also : select timestamp as timestamp from news limit 1; +-+ | timestamp | +-+ | 2002-03-25 19:45:32 | +-+ so If I do : select timestamp + 0 as timestamp from news limit 1; ++ | timestamp | ++ | 20020325194532 | ++ So i would expect a max(timestamp) + 0 to work the same than without the max. is this a bug ? (the code rely heavily on a result as a timestamp(14), like MMDDHHmmss, so getting this work helps migrating from 4.0 to 4.1) thanks for your help -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]