3 Replies Latest reply on Jun 16, 2014 7:39 AM by philmodjunk

# Date Calculation

### Title

Date Calculation

### Post

I am trying to formulate a calculation to schedule items due in the next 2 weeks. I have tried various formulas, none of which work consistently.  Can anyone help me with this?

In short I'm trying to create a script to find records from 1 year ago today and the next 13 days after that date.  Im assuming the end result would place todays date minus 1 year...todays date minus 1 year plus 13 days in the date field of my search.  I have no trouble creating the script and the search however the date calculation is baffling to me.

• ###### 1. Re: Date Calculation

What defines a record from 1 year ago, creation date? Or the last time some sort of service was provided.  Do you want exactly 1 year ago, less 14 days?

Some examples:  Today is June 14, 2014.  Show me all the records from June 28, 2013?  Or show me all the records up to June 28, 2013? Or show me all the records between June 14, 2013, & June 28, 2014?

A simple formula like Get(CurrentDate) -341 may help (365-14 equals the 341).

Something even easier is, if you can perform the find manually, when you script it, it's usually there in the perform find calc.

• ###### 2. Re: Date Calculation

That was way too simple.  Thanks for the help.

It ends up looking something like this.  SetVariable &&Two Weeks Out [Get(CurrentDate)-365 &"..." & Get(CurrentDate)-341]

This variable can be placed into any search in a script for the result I need.  I was just over thinking how to calculate the dates I needed, didn't realize FMPro would subtract from dates in that manor.

Thanks Again

• ###### 3. Re: Date Calculation

You may also want to script your finds using Set field steps as shown in the examples here: Scripted Find Examples

That makes it easier to tell what search criteria was used should you later return to this script and need to see what was used in the performed find.