如何获得当前月份获得上个月的数据 [英] How to get current month wise get last month data
问题描述
我希望本月获得当前选定的月份下拉列表(9月)使用C#或sql server获取Asp.net中的上个月数据
以下代码我正在使用但结果未来了
Sql查询:
select substring( DATENAME(MONTH,ProcessDate),1,3)作为月份来自Accounts_DailyAttendance,其中datename(MONTH,ProcessDate)='9月'
以上查询明智的数据出错,所以我想要正确的数据。
i想要的结果是十月份数据
谢谢
尝试以下
选择
substring (DATENAME(MONTH,ProcessDate), 1 , 3 ) as 月
来自
Accounts_DailyAttendance
其中
datename(MONTH,DateAdd(mm,-1,ProcessDate))= ' 9月'
试试这个
select
substring(DATENAME(MONTH,ProcessDate), 1 , 3 ) as 月
来自
Accounts_DailyAttendance
< span class =code-keyword>其中
月(ProcessDate)= DateAdd(mm,1,convert( date,'1 /'+ cast(DATEPART(MM,'九月',年(getdate()))为char(2))+'/'+ cast(year(getdate())为char(4)), 103))
I want get current selected month dropdown(september) this month get previous month data in Asp.net with C# or sql server
Below code I am using but result was not came
Sql Query:
select substring(DATENAME(MONTH, ProcessDate),1,3) as Month from Accounts_DailyAttendance where datename(MONTH,ProcessDate)='September'
The above query wise data get wrong, so i want correct data.
i want result is October month data
Thanks
Try below
select substring(DATENAME(MONTH, ProcessDate),1,3) as Month from Accounts_DailyAttendance where datename(MONTH,DateAdd(mm,-1,ProcessDate))='September'
Hi,
try this
select substring(DATENAME(MONTH, ProcessDate),1,3) as Month from Accounts_DailyAttendance where
Month(ProcessDate)=DateAdd(mm,1,convert(date,'1/'+ cast(DATEPART(MM,'September', year(getdate())) as char(2))+'/'+ cast(year(getdate()) as char(4)),103))
这篇关于如何获得当前月份获得上个月的数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!