Strange behaviour for DATEADD-months ssrs 2008. adding N months in LastDay of Month gives incorrect result in some case

  • Hi,

    I am using SSRS 2008 R2. I want to get "Next N months" date range. I have used this SSRS Expression for end date: "=DateAdd("m",4, DateAdd("d",-1,(DateAdd("m", 1, DateSerial(Year(Today), Month(Today), 1)))))". It is working fine for many scenarios but failed for case when we executing fora month having 30 days(Like June,April..) and end date will come in such month which has 31 days(Like October,December...).

    I have used below SSRS expression :

    Last day of Month : DateAdd("d",-1,(DateAdd("m", 1, DateSerial(Year(Today), Month(Today), 1))))

    Next N Months end Date : DateAdd("m",N, DateAdd("d",-1,(DateAdd("m", 1, DateSerial(Year(Today), Month(Today), 1)))))

    N=1,2,3..

    Example where I failed :

    Current Month = JUNE(a month having 30 days)

    find Next 4 months end date = 30/10/2013

    But it should be 31/10/2013.

    Please send me if anyone have solution for this.

    Thanks in advance.

    --------------------------------------------------------------------------------

  • Try this

    DATEADD("dd",-1,DATEADD("mm",DATEDIFF("mm","1901-01-01",Today())+5,"1901-01-01"))

Viewing 2 posts - 1 through 1 (of 1 total)

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