Wednesday, March 21, 2012

How to find the end month date of the particular date.

Suppose i am taking abc as input as a parameter from the user to generate report.
user input 10/20/2006 i want's to find out the end month date of this date that is 10/30/2006
or if he input 1/15/2005 |I want to find 1/31/2006.
I want to do from the report function not query.
how can i do that

> I want to do from the report function not query.

I'm not quite sure what you mean by this. I supose this means that you don't want to do it in MDX, but you don't mention what you are using as a reporting front end. In psuedo code what you would do is

1) subtract the day number from the date ( this should give you the last day of the previous month)

2) add 1 month to the date you got from the first step.

|||

Can you please give a working example ?

Do you know about any thing about date subtract in SSRS
Like I have 2/15/2007 as input parameter from report I want's to subtract 15 days and result should be like 1/31/2007

I have get the day from the date and i can add a month also in the date But I cant' find any thing about how to subtract days from the date and result should be another date

|||

You should be able to add the following in the code section of your report and then just call this function.

function GetLastDayInMonth(dt as DateTime) as DateTime

return dt.AddDays(-dt.Day).AddMonths(1)

end function

sql

No comments:

Post a Comment