Month and year from yesterday's date help

  • Hi All,

    Any help is appreciated as I think I am almost there!

    so what I want to do is from a report which contains a lot of data to select basically the data that matches the month and year of yesterday's date.

    I have this expression but am getting a red squiggle under the Today() in the first part for some reason and it won't work.

    .=sum(iif(Fields!Month_Place_Test.Value = DatePart(DateInterval.Month, DateAdd(DateInterval.Day, -1, Today()),0, iif(Fields!Year_Place_posted.Value = datepart(DateInterval.Year, Dateadd(DateInterval.Day, -1, Today()), Fields!Places_Posted.Value))))

    I am so almost there, I can feel it but can't work out where I have gone wrong.

    Thanks for the help as always

    Edited for Today not now and putting it around code heh

  • I would start with Lynn Pettis' article[/url] on common date routines. Post back if you're still stuck.

  • Your bracketing is a bit off and you need an And in there (it's easier to read then nested iif's when there are only two outcomes) - this should work:

    =sum(

    iif(

    Fields!Month_Place_Test.Value = DatePart(DateInterval.Month, DateAdd(DateInterval.Day, -1, Today())) And

    Fields!Year_Place_posted.Value = DatePart(DateInterval.Year, Dateadd(DateInterval.Day, -1, Today())),

    Fields!Places_Posted.Value, 0

    )

    )

  • Thank you both, for the link and help. It is appreciated. I have been doing more in excel so this time gave this a proper go rather than my usual ask for assistance as I didn't know where to start!

    Get me? I am terrible with brackets but getting there. I will give this a try, got some at home time off soon so going to have a swot up on expressions I think.

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply