MySql中当前月份的开始日期和结束日期?

时间:2014-05-09 11:24:12

标签: mysql

你必须在Mysql当年的任何一个日期和最后日期。

如何在where子句中找到MySql?

SET NOCOUNT ON
DECLARE @MonthStartDate As datetime
DECLARE @MonthEndDate As datetime
DECLARE @today datetime
SELECT @today = convert(varchar(12) , getdate() , 101) 

 SET @MonthStartDate = @today
 SELECT @MonthStartDate = dateadd ( dd , - datepart ( dd , @MonthStartDate ) ,  
 @MonthStartDate+1 )
 SELECT @MonthEndDate = dateadd(dd , -1 , dateadd ( mm , +1 , @MonthStartDate))
 SELECT @MonthStartDate AS StartDate , @MonthEndDate AS EndDate

1 个答案:

答案 0 :(得分:0)

使用条款

喜欢

select * from `table_name` where datetime_column as date between '01/01/2009' and curdate()