Subtract Dates

  • Hi,

    I have a report which I have on my Filter 'Current Month', hence when a month changes teh report is blank, I would like to show at least one week of data when the month changes, hope there is someone which could help me.

    I have tried DATEADD and IF functions but without any success.

    Thanks in advance

    All help and Any help is appreciated

  • Can you post the code you are using?

    How are you currently implementing Current Month?

    What are your data structures?

  • Hi,

    I been using 'Simple Date in month to date',

    also used

    AND(Simple Date >= DATE(YEAR(TODAY()), MONTH(TODAY()), 1), Simple Date < DATEADD(DAY, 1, TODAY()))

    but what I really would like is that on March 1st the report won't be blank (not a live report) but give me at least the last 7 days, possibly using 'Simple Date', something in the lines of;

    IF today() < 7 (seventh day of the month) , show me the last 7 days, otherwise show me current month to date.

    Hope this makes sense...

    🙂 Many Thanks

    All help and Any help is appreciated

  • For readability I would probably put this in Custom Code. Something like this:

    Function GetStartDate() as Date

    ' if the first of the month get last seven days

    If Today.Day = 1 Then

    Return DateAdd(DateInterval.Day, -7, Today)

    Else

    ' get the first of the month.

    Return DateAdd(DateInterval.Day, -Today.Day + 1, Today)

    End If

    End Function

    Then in the dataset:

    Where [Simple Date] >= Code.GetStartDate

  • Thanks,

    I won't have time to check it today, but I will check it tomorrow, and will let you know.

    Many Thanks,

    All help and Any help is appreciated

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

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