I use the following expression as the default parameter for a report
called 'Start':
=IIF(DATEPART("d",today()) >= "12",DateSerial(Year(today()),
Month(today()), 1) ,DateSerial(Year(today()), Month(now)-1, 1))
The query then uses the parameter to filter the data so I only get the
transactions I want depending on what day of the month it is 'today',
i.e., 'Date >= @.start'
This works fine in Report Designer in VS. However, it doesn't work once
the report is deployed and I run it through Report Manager - I get all
the transactions.
Anyone know why this is happening? I'm still using SQL2000I see two problems with your expression:
1) DatePart returns an integer not a string
2) With DateSerial(Year(today()), Month(now)-1, 1) what happens when now is
January? What Month is January minus 1?
I suggest you use the following expression:
=Iif( DatePart(DateInterval.Day, Today()>=12, DateSerial(Year(Today()),
Month(Today()),1), DateAdd(DateInterval.Month, -1, DateSerial(Year(Today()),
Month(Today()),1)))
HTH
--
Magendo_man
Freelance SQL Reporting Services developer
Stirling, Scotland
"paddydog" wrote:
> I use the following expression as the default parameter for a report
> called 'Start':
> =IIF(DATEPART("d",today()) >= "12",DateSerial(Year(today()),
> Month(today()), 1) ,DateSerial(Year(today()), Month(now)-1, 1))
> The query then uses the parameter to filter the data so I only get the
> transactions I want depending on what day of the month it is 'today',
> i.e., 'Date >= @.start'
> This works fine in Report Designer in VS. However, it doesn't work once
> the report is deployed and I run it through Report Manager - I get all
> the transactions.
> Anyone know why this is happening? I'm still using SQL2000
>
Showing posts with label iif. Show all posts
Showing posts with label iif. Show all posts
Thursday, March 22, 2012
Friday, February 24, 2012
Date Expression
I am trying to write an expression that says
iif (field.receipt date is < currentdate by 30 days, then grab field.cost,
if not then blank " ")
Basically, I am trying to write a report for aging buckets.
Thanks,
RyanOn Jun 14, 3:07 pm, Ryan Mcbee <RyanMc...@.discussions.microsoft.com>
wrote:
> I am trying to write an expression that says
> iif (field.receipt date is < currentdate by 30 days, then grab field.cost,
> if not then blank " ")
> Basically, I am trying to write a report for aging buckets.
> Thanks,
> Ryan
Something like this should work:
=iif(Fields!ReceiptDate.Value < Dateadd("d", -30, Now()), Fields!
Cost.Value, Nothing)
Regards,
Enrique Martinez
Sr. Software Consultant
iif (field.receipt date is < currentdate by 30 days, then grab field.cost,
if not then blank " ")
Basically, I am trying to write a report for aging buckets.
Thanks,
RyanOn Jun 14, 3:07 pm, Ryan Mcbee <RyanMc...@.discussions.microsoft.com>
wrote:
> I am trying to write an expression that says
> iif (field.receipt date is < currentdate by 30 days, then grab field.cost,
> if not then blank " ")
> Basically, I am trying to write a report for aging buckets.
> Thanks,
> Ryan
Something like this should work:
=iif(Fields!ReceiptDate.Value < Dateadd("d", -30, Now()), Fields!
Cost.Value, Nothing)
Regards,
Enrique Martinez
Sr. Software Consultant
Subscribe to:
Posts (Atom)