1. The Date_format () function is used to display date/time data in different formats.
The format parameter is formatted with
%a |
Abbreviated Week name |
%b |
Abbreviated month name |
%c |
month, numerical |
%d |
Days in the middle of the month with English prefixes |
%d |
Days of the month, values (00-31) |
%e |
Days of the month, values (0-31) |
%f |
Microseconds |
%H |
Hours (00-23) |
%h |
Hours (01-12) |
%I |
Hours (01-12) |
%i |
Minutes, values (00-59) |
%j |
Day of the Year (001-366) |
%k |
Hours (0-23) |
%l |
Hours (1-12) |
%m |
Month Name |
%m |
Months, values (00-12) |
%p |
AM or PM |
%r |
Time, 12-hour (Hh:mm:ss AM or PM) |
%s |
Seconds (00-59) |
%s |
Seconds (00-59) |
%T |
Time, 24-hour (HH:MM:SS) |
%u |
Week (00-53) Sunday is the first day of the week |
%u |
Week (00-53) Monday is the first day of the week |
%V |
Week (01-53) Sunday is the first day of the week, with%x use |
%v |
Week (01-53) Monday is the first day of the week, with%x use |
%w |
Week name |
%w |
Days of the week (0= Sunday, 6 = Saturday) |
%x |
Year, where Sunday was the first day of the week, 4-bit, with%V using |
%x |
Year, where Monday was the first day of the week, 4-bit, with%V using |
%Y |
Year, 4-bit |
%y |
Year, 2-bit |
Example:
Date_format (now (), '%b%d%Y%h:%i%p ')
Date_format (now (), '%m-%d-%y ') Date_format (now (),
'%d%b%Y ')
Output results:
Dec 2008 11:45 PM
12-29-2008
Dec 08
2. MySQL Format Function From_unixtime ()
SELECT from_unixtime (date, '%y-%c-%d%h:%i:%s ') as Post_date,
Date_format (now (), '%y-%c-%d%h:%i:%s ') as Post_date _gmt
1, From_unixtime (Unix_timestamp)
Parameters: typically 10-bit timestamps, such as: 1417363200
Return value: There are two types of strings that may be similar to ' Yyyy-mm-dd HH:MM:SS ', and may be similar to YYYYMMDDHHMMSS.uuuuuu
such numbers, and exactly what to return depends on the form in which the function is invoked.
Mysql> Select From_unixtime (1344887103);
+---------------------------+
| From_unixtime (1344887103) |
+---------------------------+
| 2012-08-14 03:45:03 |
+---------------------------+
2, From_unixtime (unix_timestamp, format)
Parameter unix_timestamp: The FROM_UNIXTIME( unix_timestamp )
same as the parameter meaning in the method;
Parameter format: The format in which the time string is displayed after the conversion;
Return value: A string displayed in the specified time format;
Mysql> Select From_unixtime (1344887103, '%y-%m-%d%h:%i:%s ');
+-----------------------------------------------+
| From_unixtime (1344887103, '%y-%m-%d%h:%i:%s ') |
+-----------------------------------------------+
| 2012-august-14th 03:45:03 |
+-----------------------------------------------+
1 row in Set (0.00 sec)
mysql> Select From_unixtime ( 1344887103, '%y-%m-%d%h:%i:%s ');
+-----------------------------------------------+
| From_unixtime (1344887103, '%y-%m-%d%h:%i:%s ') |
+-----------------------------------------------+
| 2012-08-14th 03:45:03 |
+-----------------------------------------------+
3, Judge is not the same day:
select Tbl_gamedata. Gamemapname,tbl_playerdata. Gamemode, Tbl_gamedata. Matchmode, Tbl_playerdata. Gameresult, SUM (tbl_playerdata. Gameiswin) as Tday_wincount, SUM (tbl_playerdata. Assistcount) as Tday_assistcount,sum (Tbl_playerdata. Killcount) as Tday_killcount, SUM (tbl_player_title. Threekill) as Tday_threekill,sum (Tbl_player_title. Fourkill) as Tday_fourkill,sum (Tbl_player_title. Fivekill) as Tday_fivekill from Tbl_playerdata left JOIN tbl_gamedata on Tbl_playerdata. GameID = Tbl_gamedata. GameID left JOIN tbl_player_title on Tbl_player_title. GameID = Tbl_playerdata. GameID and Tbl_player_title. playerID = Tbl_playerdata. playerID WHERE Tbl_playerdata. playerID = user_id and (tbl_playerdata. Gameresult = 2 OR tbl_playerdata. Gameresult = 3) and To_days (From_unixtime (tbl_playerdata. Gamestarttime) = To_days (now ()) GROUP by Tbl_gamedata. Gamemapname, Tbl_playerdata. Gamemode,tbl_gamedata. Matchmode,tbl_playerdata.
Gameresult;
Which TO_DAYS(FROM_UNIXTIME(tbl_playerdata.GameStartTime)) = TO_DAYS(NOW())
is the judgment we need.
Summarize
The above is the entire content of this article, I hope the content of this article for everyone's study or work can bring some help, if you have questions you can message exchange.