3 Replies Latest reply on Jan 11, 2013 4:45 PM by philmodjunk

# Filter portal by month/year?

### Title

Filter portal by month/year?

### Post

I'm trying to filter a portal by month.  I tried Month (Get (CurrentDate)) and I'm still seeing all other months.  Any ideas?

P.S. I have a date field in the portal that I want to reference, not sure how to plug it in.

Thanks

• ###### 1. Re: Filter portal by month/year?

Month ( Get ( CurrentDate ) ) = Month ( Portaltable::DateFIeld )

would filter by month. Use your names in place of mine for the portal's table occurrence and your date field. But you may want to filter by year as well or you might see January 2012 and January 2013 records in your portal during this month.

• ###### 2. Re: Filter portal by month/year?

Thanks that works..... Month (Get (CurrentDate)) -1  = Month (Table::Date) would yield last month? I can't seem to get this working properly

• ###### 3. Re: Filter portal by month/year?

Month (Get (CurrentDate)) -1 produces 0 instead of 12 for dates in January.

You can build in an If function that returns 12 when the month is January:

Let ( m = Month ( Get ( CurrentDate ) ) ; m = 1 ; 12 ; m - 1 )

You'll need a similar calculation to return year - 1 for the month of January as well.

Or you might use this approach:

Define a calculation field in your portal table, cMonth as DateField - Day ( Datefield ) + 1 and select Date as the return type. This returns the date for the first day of the month for all dates in date field in the same month.

Then you can use:

Date ( Month ( get ( currentDate ) ) - 1 ; 1 ; Year ( Get (currentDate ) ) ) = PortalTable::cMonth

This matches by month and date and the Date function automatically adjusts the date to be December of the previous year when the current date falls in January.