Date_format (Date,format)
Formats the date value according to the format string. The following modifiers can be used in the format string:%M month name (January ... December)
%W Week name (Sunday ... Saturday)
%d The date of the month with English prefixes (1st, 2nd, 3rd, etc.). )
%Y year, number, 4 bit
%y year, number, 2 bit
%a abbreviated weekday name (Sun ... Sat)
Number of days in the month of%d, number (00 ...). 31)
Number of days in%e month, number (0 ... 31)
%m Month, number (01 ... 12)
%c month, number (1 ... 12)
%b Abbreviated month name (Jan ... DEC)
%j Days of the year (001 ... 366)
%H hours (00 ... 23)
%k hours (0 ... 23)
%h hours (01 ... 12)
%I Hours (01 ... 12)
%l hours (1 ... 12)
%i minutes, Numbers (00 ... 59)
%r time, 12 hours (Hh:mm:ss [ap]m)
%T time, 24 hours (HH:MM:SS)
%s seconds (00 ... 59)
%s seconds (00 ... 59)
%p am or PM
%w days in one weeks (0=sunday ... 6=saturday)
%u Week (0 ... 52), here Sunday is the first day of the week
%u Week (0 ... 52), here Monday is the first day of the week
Percent of a text "%".
All other characters are not interpreted as being copied into the results.
Mysql> Select Date_format (' 1997-10-04 22:23:00 ', '%W%M%Y ');
' Saturday October 1997 '
Mysql> Select Date_format (' 1997-10-04 22:23:00 ', '%h:%i:%s ');
' 22:23:00 '
Mysql> Select Date_format (' 1997-10-04-22:23:00 ',
'%d%y%a%d%m%b%j ');
4th Sat Oct 277 '
Mysql> Select Date_format (' 1997-10-04-22:23:00 ',
'%H%k%I%r%T%s%w ');
-10:23:00 PM 22:23:00 00 6 '
In MySQL3.23,% is required before the format modifier character. In the earlier version of MySQL,% is optional.
Time_format (Time,format)
This is used like the Date_format () function above, but the format string can contain only those formatting modifiers that handle hours, minutes, and seconds.
Other modifiers produce a null value or 0.
Curdate ()
Current_date
Returns today's date value in ' Yyyy-mm-dd ' or YYYYMMDD format, depending on whether the function is used in a string or a numeric context.
Mysql> select Curdate ();
' 1997-12-15 '
Mysql> Select Curdate () 0;
http://www.bkjia.com/PHPjc/631240.html www.bkjia.com true http://www.bkjia.com/PHPjc/631240.html techarticle Date_format (Date,format) formats the DATE value according to the format string. The following modifiers can be used in the format string:%M month name (January ... December)%W Week name (Sunday ...