Showing posts with label expression. Show all posts
Showing posts with label expression. Show all posts

Wednesday, March 7, 2012

Find first and last date of a month?

Afternoon all,

Just a quickie, is there an expression built into Reporting Services from which you can find the first date and last date of any given month? The first date isn't much of a problem as it isn't quite as dynamic as the last date.

I can do it in an IIf statement but wouldn't be able to make it recognise 29th February in a leap year very easily.

Thanks,

Paul

Hello Paul,

If you have the first day of the month, you can just add a month to it and subtract a day.

=DateAdd("d", -1, DateAdd("m", 1, FirstDayOfMonth))

Hope this helps.

Jarret

|||

Hi Jarret,

Thanks for your reply, yes it helps a lot. Your solution is so simple it's brilliant.

Thanks,

Paul

|||

Phew,

Just thought I'd add this since I have proven that moving to SP2 9.0.3054 broke all my sub reports that passed a start and end date! (It blew up on the end date since the month and day were aways passed the wrong way round (i.e US when I'm en-GB)).

(No Language settings ANYWHERE fixed it, only code!)

Type in the "Code" section of report properties:

Public Function GetISODate(tmDate as DateTime)
return tmDate.Year & "-" & tmDate.Month & "-" & tmDate.Day
End Function

and use it on the navigation:
=Code.GetISODate(Parameters!<parameter>.Value)

It seems that the ISO formatted date (year-month-day) will be parsed the
same by every culture.

Credit goes to "Darren France", I just wished I'd assumed the DateTime object was in fact being passed as a date string!

Sunday, February 19, 2012

Filtering with an "In" operator

Is it possible to filter with an "In" operator? "In" is not an option when
building a filter expression so I was hoping someone found a workaround. I
plan to pass a comma-seperated list of values within quotes. The report I'm
using runs each morning and I filter that report without having to re-query
the database.
Thanks, ChrisTo do an "In" just put two of the same Filter Expression next to each other.
The And/Or column will change to Or.
For example:
=Fields!State.Value Equals WA Or
=Fields!State.Value Equals CA Or
...etc...
My employer's lawyers require me to say:
"This posting is provided 'AS IS' with no warranties, and confers no
rights."
"Chris" <chrisf@.unr.edu> wrote in message
news:u0lGTFTaEHA.972@.TK2MSFTNGP12.phx.gbl...
> Is it possible to filter with an "In" operator? "In" is not an option
when
> building a filter expression so I was hoping someone found a workaround.
I
> plan to pass a comma-seperated list of values within quotes. The report
I'm
> using runs each morning and I filter that report without having to
re-query
> the database.
> Thanks, Chris
>|||Multi-valued parameters are not supported RS 2000. Here's a related post
with a solution that might work for you:
http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&threadm=ONnNRtsBEHA.3064%40tk2msftngp13.phx.gbl&rnum=2&prev=/groups%3Fq%3D%2522in%2Bclause%2522%2Bgroup:microsoft.public.sqlserver.reportingsvcs%26hl%3Den%26lr%3D%26ie%3DUTF-8%26selm%3DONnNRtsBEHA.3064%2540tk2msftngp13.phx.gbl%26rnum%3D2
--
Ravi Mumulla (Microsoft)
SQL Server Reporting Services
This posting is provided "AS IS" with no warranties, and confers no rights.
"Chris" <chrisf@.unr.edu> wrote in message
news:u0lGTFTaEHA.972@.TK2MSFTNGP12.phx.gbl...
> Is it possible to filter with an "In" operator? "In" is not an option
when
> building a filter expression so I was hoping someone found a workaround.
I
> plan to pass a comma-seperated list of values within quotes. The report
I'm
> using runs each morning and I filter that report without having to
re-query
> the database.
> Thanks, Chris
>