7 Replies Latest reply on Mar 15, 2011 8:59 AM by philmodjunk

# Addition / Subtraction of Numbers

### Post

I am using FMP-9.  In my database, I use Julian Dates.  The Julian Date field is set as a "number field".  One operation I want to incorporate requires going forward and back by a certain number of days (eg., 500, 1000, etc.).  I have read my users manuals, but I  must be missing a step.  Is there an easy script for doing this?

Dave

• ###### 1. Re: Addition / Subtraction of Numbers

You may want to post an example of exactly what you want to do.

To change the contents of a number fields such as your julian date field, you just use the + operator to add days and the - operater to subtract days.

If Julian Date field = 500

Julian Date field + 5 computes a julian date, 505,  5 days later and

Julian date field - 5 computes a julian date, 495, 5 days earlier.

Even convential fields of type date can be used to compute dates a specified number of days in the future or past by adding or subtracting days in the same fashion though they will display as convential dates instead of as a number.

• ###### 2. Re: Addition / Subtraction of Numbers

Thank you for your post.  What you said is what the manuals said, but I don't know how to do it.  Where do I place the operation?  Do I have to create another field?

Thanks,

Dave

• ###### 3. Re: Addition / Subtraction of Numbers

That's why I asked for an example. It depends on what you need to do with the date. Such calculations can be used in scripts or in calculation fields. The calculations can use a constant such as the number 5 or you can refer to a value in another field to control the number of days to be added or subtracted.

• ###### 4. Re: Addition / Subtraction of Numbers

In the scripting: Set Variable \$myTempNewDate = MyFile::myDateField + 5

• ###### 5. Re: Addition / Subtraction of Numbers

Thank you for your notes.  Here is the example.  I have data tied to certain dates.  I have them listed with both Julian and Gregorian dates.  I would like to see what data I have for some date (for example) 1,000 days ago.  I have created a field for that information, but do not know how to perform the operation.

Thanks again,

Dave

• ###### 7. Re: Addition / Subtraction of Numbers

Then you do not need a variable and a script nor do you even need julian dates though you can use them if they are useful to you.

Say you have a number field defined as DaysInPast. Then you can define this calculation field, cJulianPast, for the Julian Date:

JulianDateField - DaysInPast

Select Number as the return type.

You can use the gregorian date fields and compute a Gregorian date with a calculation field defined as:

GregorianDateFIeld - DaysInPast

Select Date as the return type.