2017-08-22 43 views
-3

我想告诉您,我已经分析了堆栈溢出中的相同问题,但这有点改变。 我想得到比日期更大的日期,就像“8月31日”,“9月15日”一样。 在sql命令中使用这种格式是否可行?当日期格式为MM dd格式时,获取大于日期

+0

这不是一个日期作为该格式 –

+0

三江源@Rory McCrossan串真的可行。 :) 我在问题中提到,我知道这是同一个问题,但日期格式不同,不知道为什么人们对它有负面评价。 – Boyka

+0

好悲伤,只是将日期存储为日期。 – Strawberry

回答

0

可能,如果你使用STR_TO_DATE并承担所有日期为当年 例如

select str_to_date((concat(year(sysdate()),'-','August 17')),'%Y-%M %d'); 
+-------------------------------------------------------------------+ 
| str_to_date((concat(year(sysdate()),'-','August 17')),'%Y-%M %d') | 
+-------------------------------------------------------------------+ 
| 2017-08-17              | 
+-------------------------------------------------------------------+ 
1 row in set (0.00 sec) 

MariaDB [sandbox]> select case when date(now()) > str_to_date((concat(year(sysdate()),'-','August 17')),'%Y-%M %d') then 'Now Gt in date' 
    -> else 'Now Lt in date' 
    -> end msg; 
+----------------+ 
| msg   | 
+----------------+ 
| Now Gt in date | 
+----------------+ 
1 row in set (0.00 sec) 
相关问题