August 4, 2011 at 10:29 am
Hi ...
I wrote this expression: =DateAdd("m", -3, DateSerial(Year(Now()), Month(Now()), 1)) this is giving me 5/1/2011.
IS this correct ?
Thanks,
Komal
August 4, 2011 at 11:33 am
Looks pretty good to me. Test it with a few dates other than Now() and you will probably find that you will get what you want.
August 4, 2011 at 1:08 pm
Here is a large number of date routines that you might want to save for future reference.
https://www.sqlservercentral.com/blogs/lynnpettis/archive/2009/03/25/some-common-date-routines.aspx
August 4, 2011 at 1:25 pm
From the link in my prior post .. have some fun with finding the 1st day of the prior month
DECLARE @I INT
SET @I = 0
WHILE @I < 13
BEGIN
select dateadd(mm, datediff(mm, 0, GETDATE()) - @I, 0) AS 'Firstof month',
DATENAME ( dw ,dateadd(mm, datediff(mm, 0, GETDATE()) - @I, 0) ) AS 'First day of month'
SET @I = @I + 1
END
Shorened sample of the results:
First of month First day of month
----------------------- ---------------------
2011-08-01 00:00:00.000 Monday
2011-07-01 00:00:00.000 Friday
2011-06-01 00:00:00.000 Wednesday
2011-05-01 00:00:00.000 Sunday
August 4, 2011 at 1:56 pm
Thank you....I have another issue with datepart .I have @Year and @Month values comming from Parameter.
I need to write expression to get the 12month rolling date ,selected month and year values from parameters.
I tried with previous expression in ssrs but getting errors.Any other way to get 12 month date?
Thanks,
Komal
August 4, 2011 at 2:45 pm
What do you mean by a 12 month date?
August 4, 2011 at 3:03 pm
I want to get the past 12months date depending on the parameters chosen from report!!!!! I need to write an expression to get it...but getting errors:
=DATEADD("MM",DATEDIFF("MM",0,Parameters!RunMonth.Value)-11,0)
tried different ways...:(
August 4, 2011 at 10:30 pm
komal145 (8/4/2011)
I want to get the past 12months date depending on the parameters chosen from report!!!!! I need to write an expression to get it...but getting errors:=DATEADD("MM",DATEDIFF("MM",0,Parameters!RunMonth.Value)-11,0)
tried different ways...:(
Just slightly confused!!!!! (Were all those explanation points really needed?)
Please provide an example of what the date range would be based on a specific date input.
Viewing 8 posts - 1 through 7 (of 7 total)
You must be logged in to reply to this topic. Login to reply