mysql query the current date

1. This Year

SELECT DATE_FORMAT(NOW(), '%Y');

2. This month (digital display)

SELECT DATE_FORMAT(NOW(), '%m');

3. This month (display in English)

SELECT DATE_FORMAT(NOW(), '%M');

4. the date (display numbers)

SELECT DATE_FORMAT(NOW(), '%d');

5. the date (display numbers and letters, such as: 16th)

SELECT DATE_FORMAT(NOW(), '%D');

6. The current time (11:54:23)

SELECT DATE_FORMAT(NOW(), '%T');

7. current time (11:54:23)

 select DATE_FORMAT(now(),'%Y-%m-%d %h:%i:%s') from dual;

 

The following modifiers can be used in the format string:

% M month name (January ...... December)
% W week name (Sunday ...... Saturday)
% D dated January English prefix (1st, 2nd, 3rd, etc.) %
In the Y-digital, four
% y in digital, two
% a abbreviated weekday name (Sun ...... Sat)
the number of days in the month% d, digital (00 ...... 31)
days of the month% e, numbers (0 ...... 31)
% m month, digital (01 ...... 12)
% c month, numbers (1 ...... 12)
% b abbreviated month name (Jan ...... Dec)
the number of days in the% j year (001 ...... 366)
% H hour (00 ...... 23 is)
% K h (0 ...... 23 is)
% h H (01 ...... 12 is)
% the I h (01 ...... 12 is)
% L h (12 is ....... 1)
% I min, numbers (00 ...... 59)
% r time, 12 hours (HH: mm: SS [the AP] M)
% T time, 24 hours (HH: mm: SS)
% S seconds (00 ...... 59)
% S seconds (00 ...... 59)
% P AM or the PM
% W number of days of the week (0 = Saturday the Sunday = ....... 6) %
the U-week (0 ...... 52), where Sunday is the first day of the week
% u week (0 ...... 52), where Monday It is the first day of the week
%% a literal "%."

Guess you like

Origin www.cnblogs.com/smallVampire/p/12020774.html