3 Replies Latest reply on Aug 27, 2012 12:18 PM by StewartMcadoo

# Current Date in a calculation

### Title

Current Date in a calculation

### Post

I can't seem to get anything to work.  I want to get the number of days from a date in the past to today for a calculation of a field in my db.  Seems from documentation that "Get(currentdate) - DatePast"  should work but I get a "?"  I tried a new field called "Current Date" with a calculation of ony "Get(currentdate)" and I get nothing when displaying that field.  What to I have to use to get the number of days calculation to work?

• ###### 1. Re: Current Date in a calculation

If DatePast is a field of Type date and you select "Number" as the calculation field's return type, this should work. The calculation should also be specified as "unstored" so that it updates to compute a new elapsed days as time passes.

• ###### 2. Re: Current Date in a calculation

Field  [type Date] named "DatePast"

Field [type Calculation result Number] named "NumberofDays"
Calculation  -  Get(currentdate) - DatePast

http://help.filemaker.com/app/answers/detail/a_id/5544/kw/future%20date%20calculations
How do I calculate the difference between dates in FileMaker Pro?

Answer ID: 5544
Last Updated: Sep 20, 2011

If you have two date fields, and you wish to find the number of days between them, you simply subtract the earlier date from the later date in a calculation field.
These examples assume that you have the following fields:

StartDate (date)
EndDate (date)

Define a calculation field with a number result with this formula:

StartDate -  EndDate

By doing so, FileMaker will return a number in the calculation field. If the date was "7/27/2005" in "StartDate" and the "EndDate" was "8/3/2005" then using the above calculation would return "-7".
Alternatively, you can swap the EndDate with the StartDate in the calculation field and get "7".
To find a date in the future, you simply add the number of days in the future to the existing date within a calculation field with a date result:

StartDate + "X"

The effect from this would be whatever is in your defined date field (StartDate) will have X number of days added to it:
If "StartDate" was "7/27/2005" and "X" was "7" the result would be "8/3/2005"

GOING THE OTHER DIRECTION

http://help.filemaker.com/app/answers/detail/a_id/4129/~/calculating-due-dates-specific-to-each-record-in-the-database
Calculating Due Dates Specific to Each Record in the Database
You have a date field, and you want to create a due date based on that field value. You may need to keep track of your credit card grace periods, or you may want to set up a due date for your customers as to when you should send them invoices. Here are several methods to set up that due date.

It is assumed that the following fields already exist:
StartDate (Date)
NumberOfDays (Number)

[NOTE: for clarity, the following format is used when itemizing required fields:
field name (field type) = formula
where the field name is first, the field type in parentheses is second, and the field formula preceded with an = sign is last. Formulas that are lengthy will start on a separate line from the field name.]

Method 1.
If you have a specific number of days you always want to add (say you want the due date to always be 30 days from the Start Date Field) then you have a choice of two calculations you can use:
ThirtyDayDueDate1 (Calculation, Date result) = StartDate + 30

Examples:
StartDate ThirtyDayDueDate1
03/06/94 04/05/94
04/01/94 05/01/94
05/01/94 05/31/94
07/04/94 08/03/94
12/05/94 01/04/95

OR
ThirtyDayDueDate2 (Calculation, Date result) = Date (Month (StartDate), Day (StartDate) + 30, Year (StartDate))

Examples:
StartDate ThirtyDayDueDate2
03/06/94 04/05/94
04/01/94 05/01/94
05/01/94 05/31/94
07/04/94 08/03/94
12/05/94 01/04/95

NOTE: The results are the same for either calculation. Use the one that is easier for you.

Method 2.
But suppose you want to be able to vary that due date. Using the field called NumberOfDays (see above), enter the number you want to be the number of days away from the StartDate. You may want the due date to come up in 30 days, maybe 60 days, or 90 days, etc. Just enter the desired number in the NumberOfDays field. The following calculations will then take that number and compute the due date:

VariableDueDate1 (Calculation, Date result) = StartDate + NumberOfDays

Examples:
StartDate NumberOfDays VariableDueDate1
03/06/94 30 04/05/94
04/01/94 60 05/31/94
05/01/94 75 07/15/94
07/04/94 90 10/02/94
12/05/94 120 04/04/95

OR
VariableDueDate2 (Calculation, Date result) = Date (Month (StartDate), Day (StartDate) + NumberOfDays, Year (StartDate))

Examples:
StartDate NumberOfDays VariableDueDate2
03/06/94 30 04/05/94
04/01/94 60 05/31/94
05/01/94 75 07/15/94
07/04/94 90 10/02/94
12/05/94 120 04/04/95

• ###### 3. Re: Current Date in a calculation

thanks to both of you.  I had the receiving field as a number, not calculation.  It now works correctly.