2 Replies Latest reply on Dec 30, 2008 2:33 PM by comment_1

# Calculate Number of Weeks and days DueDate-CurrentDate

### Title

Calculate Number of Weeks and days DueDate-CurrentDate

### Post

Hello,

I am having some trouble doing a simple calculation.

I want to calculate the number of weeks and days from the due date to the current date. If this is a negitive number that is fine.

I'd like to keep the weeks seperated from the days because I want to sort and report on the weeks from due date.

Examples:

Due: 12/25/2008 Current Date: 12/30/2008 = 0 weeks -5 days

Due: 12/16/2008 Current Date: 12/30/2008 = -2 weeks 0 days

Due: 1/17/2009 Current Date: 12/30/2008 = 2 weeks -1 days

I am calculating the weeks

Int ( (ReleaseDate-Get ( CurrentDate ))/7 )

And Days

Mod ( ReleaseDate-Get ( CurrentDate ) ; (Sign ( ReleaseDate-Get ( CurrentDate ) ))*7 )

Is there a betterway to do this? (actualy this is the way I came up with while typing the question and is working pretty well.)

Also I changed the date (4 days ahaed) on my system to run a report (reset date) and it seemed to mess up (all 4 days behind) my date calculations. So much so that I had to re-import all the records again to make the date math correct.

Is there anyplace to reset this?

Thank you,

--StevenKW

• ###### 1. Re: Calculate Number of Weeks and days DueDate-CurrentDate
difference in days is date_end - date_start

The rest is done with these two functions:

mod() -> http://filemaker.com/help/FunctionsRef-330.html
div() -> http://filemaker.com/help/FunctionsRef-322.html

Jens

• ###### 2. Re: Calculate Number of Weeks and days DueDate-CurrentDate
You should be aware that in Filemaker 7 and higher, Mod ( -5 ; 7 ) returns 2, not -5 as you probably expect. So perhaps you need something like:

Let (
n = ReleaseDate - Get (CurrentDate)
;
Mod ( Abs ( n ) ; 7 ) * Sign ( n )
)

to calculate the days part.