如何在MySQL日期中提取Month和Year并进行比较? [英] How do I extract Month and Year in a MySQL date and compare them?

查看:1663
本文介绍了如何在MySQL日期中提取Month和Year并进行比较?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何从mySQL日期中提取月份和日期,并将其与另一个日期进行比较?

How do I extract the month and date from a mySQL date and compare it to another date?

我发现这个MONTH(),但只能获得月份。我在寻找月和年。

I found this MONTH() but it only gets the month. I looking for month and year.

推荐答案

在Mysql Doku:
http://dev.mysql.com/doc/refman/5.5/en/date -and-time-functions.html#function_extract

in Mysql Doku: http://dev.mysql.com/doc/refman/5.5/en/date-and-time-functions.html#function_extract

SELECT EXTRACT( YEAR_MONTH FROM `date` ) 
FROM `Table` WHERE Condition = 'Condition';

这篇关于如何在MySQL日期中提取Month和Year并进行比较?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆