This is a discussion on Datetime(14) return value differences between MySQL v. 4.x and 3.x within the MySQL Database forums, part of the Database Forums category; Hi Is there any way to force the output format of datetime fields in MySQL versions from 4.0? We ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
Hi
Is there any way to force the output format of datetime fields in MySQL versions from 4.0? We have a few large databases running on v. 3.something and we are running several different applicatons that make a presumption that the return values of datetime(14) are formatted to 'YYYYMMDDHHMMSS'. However, the new versions seem to return it like '2006-01-02 12:12:50'. Can I somehow make it return this like '20060102121250', the way it works on v. 3.x.y? There are just too many places that would need a change in code that it wouldn't be possible to handle them all. A few tries of googling about this didn't give me too much hope. I bet someone has faced the same problem and solved it. -- AH |
|
|||
|
"Asteri Hakola" <no.email@com.invalid> wrote in message
news:pan.2006.03.07.15.45.31.975514@com.invalid... > the new versions seem to return it like > '2006-01-02 12:12:50'. Can I somehow make it return this like > '20060102121250', the way it works on v. 3.x.y? I'm using NOW() as a datetime value in the following examples; you can use any datetime field or expression. A datetime value can be coerced to an integer by putting it in an integer context: SELECT NOW() + 0; Or you can format any datetime value with great flexibility using the DATE_FORMAT() function: SELECT DATE_FORMAT(NOW(), '%Y%m%d%k%i%s'); See http://dev.mysql.com/doc/refman/4.1/...functions.html entries for NOW() and DATE_FORMAT(). Regards, Bill K. |
|
|||
|
On Tue, 07 Mar 2006 10:34:55 -0800, Bill Karwin wrote:
> I'm using NOW() as a datetime value in the following examples; you can use > any datetime field or expression. > > A datetime value can be coerced to an integer by putting it in an integer > context: > SELECT NOW() + 0; > > Or you can format any datetime value with great flexibility using the > DATE_FORMAT() function: > SELECT DATE_FORMAT(NOW(), '%Y%m%d%k%i%s'); Thanks for your answer, but as far as I understand, this would need changes to current queries, and changes to software are not possible in this situation. What I need is backwards compatibility, not rewriting and compiling code and installing new binaries when just upgrading from v.3 to v.4 or v.5 -- AH |