我希望得到这个月的第一天和最后一天
select CONVERT(varchar,dateadd(d,-1,dateadd(m,1,cast(cast('201812' as varchar(6))+'01' as date))),112)实际上,我可以得到每月的最后一天,但我不知道如何才能获得每月的第一天。
发布于 2020-04-14 06:03:24
如果你从'201801asyyyymm`‘开始,那么使用:
select convert(date, yyyymm + '01') as first_day_of_month,
eomonth(convert(date, yyyymm + '01')) as last_day_of_monthhttps://stackoverflow.com/questions/61197544
复制相似问题