List:General Discussion« Previous MessageNext Message »
From:Mike Little Date:May 11 1999 2:28pm
Subject:Date_format() does not ignore letters without %
View as plain text  
Apologies for not using mysql-bug (it requires a *nix machine with a configured mail 
system)

I have discovered a problem with date_format(), it is interpreting formatting chars
it 'knows' even without a preceding '%'

mysql> SELECT DATE_FORMAT(NOW(),'%W, %e %M %Y %H:%i:%S GMT') as today, VERSION()\G
*************************** 1. row ***************************
    today: Tuesday, 11 May 1999 14:15:49 GMay14:15:49
version(): 3.22.20a
1 row in set (0.00 sec)

and on another machine

mysql> SELECT DATE_FORMAT(NOW(),'%W, %e %M %Y %H:%i:%S GMT') as today, VERSION()\G
*************************** 1. row ***************************
    today: Tuesday, 11 May 1999 13:56:39 GMay13:56:39
version(): 3.22.21
1 row in set (0.00 sec)

(Yes I have just spotted that the two machines are nowhere near in sync with each 
other.)

These are both running Linux (RedHar 5.2 kernel 2.0.36)

And under Windows NT

mysql> SELECT DATE_FORMAT(NOW(),'%W, %e %M %Y %H:%i:%S GMT') as today, VERSION()\G
*************************** 1. row ***************************
    today: Tuesday, 11 May 1999 15:00:09 GMay15:00:09
version(): 3.22.22
1 row in set (0.00 sec)

(This one has a much more accurate time)


UPDATE:
Having looked at the source in item_timefunc.cc
It looks like the manual (3.22.22) is ahead of the source and in fact '%' is not 
required at all.

Which I've just verified...

mysql> SELECT DATE_FORMAT(NOW(),'W, e M Y T ') as today, VERSION() \G
*************************** 1. row ***************************
    today: Tuesday, 11 May 1999 14:46:24 
version(): 3.22.20a
1 row in set (0.00 sec)

So I guess the leading % is going to be in the next version.

And how about an extension to get the timezone of the server machine into the 
Date_Format() string?


Mike

--
Mike Little
email: mike@stripped
work: MLittle@stripped
web: http://www.amprsoft.demon.co.uk/
PGP public key at http://www.amprsoft.demon.co.uk/mikel.htm
Thread
Date_format() does not ignore letters without %Mike Little11 May
  • Re: Date_format() does not ignore letters without %Christian Mack11 May
  • Date_format() does not ignore letters without %Michael Widenius11 May