sql - DateAdd Syndrome -
sql - DateAdd Syndrome -
i used ton of keywords search info on nil popped every time nail enter, that's little surprising me.
my question this:
i have functions in query homecoming me specific area of time in month of gross sales week. looks this:
declare @startdate datetime, @enddate datetime set @startdate= **dateadd(wk, datediff(wk, 6, getdate()), 6)** set @enddate= **dateadd(wk, datediff(wk, 6, getdate()), 12)** exec dbo.lvs_salessummaryrpt @enddate =@enddate, @startdate = @startdate
and have 1 entire month well:
declare @startdate datetime, @enddate datetime set @startdate=**convert(varchar(25),dateadd(dd,-(day(getdate())-1),getdate()),101)** set @enddate=**dateadd(s,-1,dateadd(mm, datediff(m,0,getdate())+1,0))** exec dbo.lvs_salessummaryrpt @enddate =@enddate, @startdate = @startdate
now areas i've bolded, i've copied , pasted select in new dataset in ssrs, new datasets can apply look =first(fields!begofweek.value, "weekds") it'll homecoming me timeframe whatever month looking at. great, same day. cannot life of me figure out how days, specifically, 6th , 7th of month.
i'm extremely new syntax, , reason have other examples because provided me, i'm having hard time grasping these date functions , how them work , feeling quite stupid @ moment.
can help me?
i unable bold code due it's format, please note areas surrounded *'s
i guess give more information. dataset have day thus:
declare @startdate datetime, @enddate datetime set @startdate='11/6/2014' set @enddate='11/7/2014' exec dbo.lvs_salessummaryrpt @enddate =@enddate, @startdate = @startdate
and hope can see confusion, cannot utilize 11/6/2014 , 11/7/2014 because static dates , need dynamic month want.
i have answered own question believe, working should.
select dateadd(mm,datediff(mm,0,getdate()),5) begday select dateadd(mm,datediff(mm,0,getdate()),6) endday
it's been tedious couple of days feeling more , more comfortable. thing need work on not freaking f out whenever run new. thanks..... who? me!
the rest of you, hope helps, uncertainty going have problem. i'm newb.
just crap of it, had convert format did not want display hours. did day , month.
day:
select convert(date,getdate()) begday, convert(date,dateadd(d,1,getdate())) endday
month:
select convert(varchar(25),dateadd(dd,-(day(getdate())-1),getdate()),101) begofmonth, convert(date,dateadd(s,-1,dateadd(mm, datediff(m,0,getdate())+1,0))) endofmonth
sql reporting-services ssrs-2008
Comments
Post a Comment