Skip to main content
Announcements
SYSTEM MAINTENANCE: Thurs., Sept. 19, 1 AM ET, Platform will be unavailable for approx. 60 minutes.
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Macro to select latest 12 months

Hello everyone,

I know macros are bad and i should not use them..

But i have to know this.

Can anyone help me with the syntax of macro to select latest 12 months from a date dimension.

ActiveDocument.Fields("ShipDate","State-A").Select ActiveDocument.Evaluate("date(date#(addmonths(max(ShipDate),-12),'DD-MM-YYYY'),'DD-MM-YYYY')")

The above helps me select max-12 month.

But i want to select all last 12 months?

Thanks

khushboo

1 Solution

Accepted Solutions
marcus_sommer

Try this:

ActiveDocument.Fields("ShipDate","State-A").Select ">=" & ActiveDocument.Evaluate("date(date#(addmonths(max(ShipDate),-12),'DD-MM-YYYY'),'DD-MM-YYYY')")

- Marcus

View solution in original post

2 Replies
marcus_sommer

Try this:

ActiveDocument.Fields("ShipDate","State-A").Select ">=" & ActiveDocument.Evaluate("date(date#(addmonths(max(ShipDate),-12),'DD-MM-YYYY'),'DD-MM-YYYY')")

- Marcus

Not applicable
Author

Thanks Marcus 🙂